web-component-design

📁 mileycy516-stack/skills 📅 8 days ago
1
总安装量
1
周安装量
#55276
全站排名
安装命令
npx skills add https://github.com/mileycy516-stack/skills --skill web-component-design

Agent 安装分布

mcpjam 1
claude-code 1
replit 1
junie 1
windsurf 1
zencoder 1

Skill 文档

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 composition patterns (Compound Comps, Slots, Render Props)
  • Choosing CSS-in-JS solutions (Tailwind, Styled Components)
  • Building accessible, responsive UI
  • Refactoring legacy components

Workflow

  1. Define API: Design the Props interface (semantic naming, defaults).
  2. Choose Strategy: Compound component vs Monolithic configuration?
  3. Implement: Build structure, styles (CVA), and behavior.
  4. Refine: Add Accessibility (ARIA) and Forward Refs.

Instructions

1. Component Composition Patterns

Compound Components (React): Allow flexible layouts by breaking components into parts sharing state internally.

<Select>
  <Select.Trigger>Choose</Select.Trigger>
  <Select.Options>...</Select.Options>
</Select>

Slots (Vue/Svelte): Named content injection points for flexible templates.

<Card>
  <template #header>Title</template>
  <template #content>Body</template>
</Card>

2. Styling Approaches

  • Tailwind + CVA: Best for modern Design Systems. Type-safe variants.
  • CSS Modules: Best for isolating styles in legacy apps.
  • Styled-Components: Good for dynamic JS-driven styles.

3. Component API Design (Props)

  • Boolean Flags: isLoading, isDisabled (is[Adjective]).
  • Variants: variant="primary", size="lg".
  • Composition: Always accept children or slots.
  • Overrides: Always accept className or style to allow user customization.

4. Framework Examples

Resources