본문으로 건너뛰기
Skillpedia
인터페이스 (UI/UX)41k · #6809

web-component-design

하는 일

이 도구는 웹사이트와 앱을 위한 재사용 가능하고 체계적인 사용자 인터페이스 컴포넌트를 만들도록 돕습니다. React, Vue, Svelte 같은 기술을 사용해 효율적이고 세련되게 컴포넌트를 만드는 패턴을 가르칩니다.

사용하는 경우

  • ✓프로젝트를 위한 시각 컴포넌트 라이브러리를 만들 때.
  • ✓버튼, 카드, 기타 요소의 모습과 동작을 디자인할 때.
  • ✓컴포넌트에 스타일(색, 글꼴, 크기)을 어떻게 적용할지 정할 때.

스킬 링크

https://github.com/wshobson/agents/blob/main/plugins/ui-design/skills/web-component-design/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/wshobson/agents/blob/main/plugins/ui-design/skills/web-component-design/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“React에서 색이 다르고 아이콘을 넣을 수 있는 재사용 가능한 버튼은 어떻게 만들 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 컴포넌트들이 잘 어울리도록 결합하는 여러 방법, 예를 들어 '복합 컴포넌트'나 '슬롯'을 가르칩니다. 또한 CSS-in-JS 같은 다양한 컴포넌트 스타일링 방법도 보여 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Web Component Design

Build reusable, maintainable UI components using modern frameworks with clean composition patterns and styling approaches.

When to Use This Skill

  • Designing reusable component libraries or design systems
  • Implementing complex component composition patterns
  • Choosing and applying CSS-in-JS solutions
  • Building accessible, responsive UI components
  • Creating consistent component APIs across a codebase
  • Refactoring legacy components into modern patterns
  • Implementing compound components or render props

Core Concepts

1. Component Composition Patterns

Compound Components: Related components that work together

// Usage
<Select value={value} onChange={setValue}>
  <Select.Trigger>Choose option</Select.Trigger>
  <Select.Options>
    <Select.Option value="a">Option A</Select.Option>
    <Select.Option value="b">Option B</Select.Option>
  </Select.Options>
</Select>

Render Props: Delegate rendering to parent

<DataFetcher url="/api/users">
  {({ data, loading, error }) =>
    loading ? <Spinner /> : <UserList users={data} />
  }
</DataFetcher>

Slots (Vue/Svelte): Named content injection points

<template>
  <Card>
    <template #header>Title</template>
    <template #content>Body text</template>
    <template #footer><Button>Action</Button></template>
  </Card>
</template>

2. CSS-in-JS Approaches

Solution Approach Best For
Tailwind CSS Utility classes Rapid prototyping, design systems
CSS Modules Scoped CSS files Existing CSS, gradual adoption
styled-components Template literals React, dynamic styling
Emotion Object/template styles Flexible, SSR-friendly
Vanilla Extract Zero-runtime Performance-critical apps

3. Component API Design

interface ButtonProps {
  variant?: "primary" | "secondary" | "ghost";
  size?: "sm" | "md" | "lg";
  isLoading?: boolean;
  isDisabled?: boolean;
  leftIcon?: React.ReactNode;
  rightIcon?: React.ReactNode;
  children: React.ReactNode;
  onClick?: () => void;
}

Principles:

  • Use semantic prop names (isLoading vs loading)
  • Provide sensible defaults
  • Support composition via children
  • Allow style overrides via className or style

Quick Start: React Component with Tailwind

import { forwardRef, type ComponentPropsWithoutRef } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";

const buttonVariants = cva(
  "inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50",
  {
    variants: {
      variant: {
        primary: "bg-blue-600 text-white hover:bg-blue-700",
        secondary: "bg-gray-100 text-gray-900 hover:bg-gray-200",
        ghost: "hover:bg-gray-100 hover:text-gray-900",
      },
      size: {
        sm: "h-8 px-3 text-sm",
        md: "h-10 px-4 text-sm",
        lg: "h-12 px-6 text-base",
      },
    },
    defaultVariants: {
      variant: "primary",
      size: "md",
    },
  },
);

interface ButtonProps
  extends
    ComponentPropsWithoutRef<"button">,
    VariantProps<typeof buttonVariants> {
  isLoading?: boolean;
}

export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
  ({ className, variant, size, isLoading, children, ...props }, ref) => (
    <button
      ref={ref}
      className={cn(buttonVariants({ variant, size }), className)}
      disabled={isLoading || props.disabled}
      {...props}
    >
      {isLoading && <Spinner className="mr-2 h-4 w-4" />}
      {children}
    </button>
  ),
);
Button.displayName = "Button";

Framework Patterns

React: Compound Components

import { createContext, useContext, useState, type ReactNode } from "react";

interface AccordionContextValue {
  openItems: Set<string>;
  toggle: (id: string) => void;
}

const AccordionContext = createContext<AccordionContextValue | null>(null);

function useAccordion() {
  const context = useContext(AccordionContext);
  if (!context) throw new Error("Must be used within Accordion");
  return context;
}

export function Accordion({ children }: { children: ReactNode }) {

…
자주 묻는 질문

'복합 컴포넌트'란 무엇인가요?

하나의 묶음으로 함께 작동하는 컴포넌트입니다. 예를 들어 선택 컴포넌트는 선택된 옵션을 보여 주는 부분, 옵션 목록, 목록의 각 항목이 따로 있지만 하나의 단위로 작동합니다.

'CSS-in-JS'란 무엇인가요?

스타일 코드(CSS)를 컴포넌트 코드(JavaScript/TypeScript) 안에 직접 쓰는 방식입니다. 더 동적이고 체계적인 스타일링이 가능합니다.

'컴포넌트 API 설계'는 무엇을 뜻하나요?

컴포넌트가 받는 옵션과 속성(색, 크기, 비활성화 여부 등)을 정의하는 방식입니다. 다른 개발자가 쉽게 사용할 수 있도록 하기 위함입니다.

상세 정보

작성자의 원본 설명

Master React, Vue, and Svelte component patterns including CSS-in-JS, composition strategies, and reusable component architecture. Use when building UI component libraries, designing component APIs, or implementing frontend design systems.

repo: wshobson/agents

인기도

GitHub 스타
41k
순위
#6809
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬