Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
wshobson avatar

Web Component Design

  • 10.6k installs
  • 38.5k repo stars
  • Updated July 22, 2026
  • wshobson/agents

How to design, architect, and implement reusable UI components across React, Vue, and Svelte with clean composition and styling patterns.

About

This skill teaches developers how to architect maintainable component libraries and design systems across React, Vue, and Svelte. It covers composition patterns (compound components, render props, slots), CSS-in-JS solutions (Tailwind, styled-components, Emotion, CSS Modules, Vanilla Extract), and component API design principles. Developers use this when building UI component libraries, implementing design systems, refactoring legacy components into modern patterns, or designing accessible, responsive components. Key workflows include choosing appropriate styling approaches, preventing prop drilling with context, implementing controlled/uncontrolled patterns, and applying memoization to optimize renders.

  • Compound components, render props, and slots for flexible component composition
  • CSS-in-JS comparison table covering Tailwind, styled-components, Emotion, CSS Modules, Vanilla Extract
  • Complete React Button component example with variants via class-variance-authority and Tailwind
  • Accordion and Tabs implementations showing context-based state management patterns
  • Best practices including accessibility defaults, error boundaries, and re-render optimization

Web Component Design by the numbers

  • 10,559 all-time installs (skills.sh)
  • +202 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #53 of 2,245 Frontend Development skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

web-component-design capabilities & compatibility

Capabilities
design component composition patterns (compound, · architect reusable component apis with semantic · implement css in js solutions with styling strat · build accessible, responsive components with ari · optimize render performance with memoization and · refactor legacy components into modern patterns
Use cases
frontend · ui design · web design
From the docs

What web-component-design says it does

Master React, Vue, and Svelte component patterns including CSS-in-JS, composition strategies, and reusable component architecture.
web-component-design.md - description
Use when building UI component libraries, designing component APIs, or implementing frontend design systems.
web-component-design.md - description
npx skills add https://github.com/wshobson/agents --skill web-component-design

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs10.6k
repo stars38.5k
Security audit3 / 3 scanners passed
Last updatedJuly 22, 2026
Repositorywshobson/agents

What it does

Design and build reusable UI components using React, Vue, or Svelte with clean composition patterns and styling strategies.

Who is it for?

Building UI component libraries, design systems, refactoring legacy components, implementing accessible component APIs, choosing CSS-in-JS solutions.

Skip if: Non-frontend work, backend API design, DevOps tooling, data engineering.

When should I use this skill?

Starting a design system project, designing component APIs, choosing CSS-in-JS tools, implementing complex component composition, refactoring UI code.

What you get

Developers deliver maintainable, reusable component libraries with clear APIs, proper composition patterns, and optimized rendering performance.

  • Component architecture design
  • Component API specification
  • CSS-in-JS implementation choice

By the numbers

  • 5 CSS-in-JS solutions covered (Tailwind, CSS Modules, styled-components, Emotion, Vanilla Extract)
  • 3 framework implementations provided (React, Vue 3, Svelte 5)
  • 7 best practices documented

Files

SKILL.mdMarkdownGitHub ↗

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

SolutionApproachBest For
Tailwind CSSUtility classesRapid prototyping, design systems
CSS ModulesScoped CSS filesExisting CSS, gradual adoption
styled-componentsTemplate literalsReact, dynamic styling
EmotionObject/template stylesFlexible, SSR-friendly
Vanilla ExtractZero-runtimePerformance-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 }) {
  const [openItems, setOpenItems] = useState<Set<string>>(new Set());

  const toggle = (id: string) => {
    setOpenItems((prev) => {
      const next = new Set(prev);
      next.has(id) ? next.delete(id) : next.add(id);
      return next;
    });
  };

  return (
    <AccordionContext.Provider value={{ openItems, toggle }}>
      <div className="divide-y">{children}</div>
    </AccordionContext.Provider>
  );
}

Accordion.Item = function AccordionItem({
  id,
  title,
  children,
}: {
  id: string;
  title: string;
  children: ReactNode;
}) {
  const { openItems, toggle } = useAccordion();
  const isOpen = openItems.has(id);

  return (
    <div>
      <button onClick={() => toggle(id)} className="w-full text-left py-3">
        {title}
      </button>
      {isOpen && <div className="pb-3">{children}</div>}
    </div>
  );
};

Vue 3: Composables

<script setup lang="ts">
import { ref, computed, provide, inject, type InjectionKey } from "vue";

interface TabsContext {
  activeTab: Ref<string>;
  setActive: (id: string) => void;
}

const TabsKey: InjectionKey<TabsContext> = Symbol("tabs");

// Parent component
const activeTab = ref("tab-1");
provide(TabsKey, {
  activeTab,
  setActive: (id: string) => {
    activeTab.value = id;
  },
});

// Child component usage
const tabs = inject(TabsKey);
const isActive = computed(() => tabs?.activeTab.value === props.id);
</script>

Svelte 5: Runes

<script lang="ts">
  interface Props {
    variant?: 'primary' | 'secondary';
    size?: 'sm' | 'md' | 'lg';
    onclick?: () => void;
    children: import('svelte').Snippet;
  }

  let { variant = 'primary', size = 'md', onclick, children }: Props = $props();

  const classes = $derived(
    `btn btn-${variant} btn-${size}`
  );
</script>

<button class={classes} {onclick}>
  {@render children()}
</button>

Best Practices

1. Single Responsibility: Each component does one thing well 2. Prop Drilling Prevention: Use context for deeply nested data 3. Accessible by Default: Include ARIA attributes, keyboard support 4. Controlled vs Uncontrolled: Support both patterns when appropriate 5. Forward Refs: Allow parent access to DOM nodes 6. Memoization: Use React.memo, useMemo for expensive renders 7. Error Boundaries: Wrap components that may fail

Common Issues

  • Prop Explosion: Too many props - consider composition instead
  • Style Conflicts: Use scoped styles or CSS Modules
  • Re-render Cascades: Profile with React DevTools, memo appropriately
  • Accessibility Gaps: Test with screen readers and keyboard navigation
  • Bundle Size: Tree-shake unused component variants

Related skills

How it compares

Choose web-component-design when the goal is cross-framework component architecture and design-system consistency rather than a single-page layout or backend API work.

FAQ

What is the difference between compound components and render props?

Compound components group related components that share state via context (e.g., Select with Select.Trigger and Select.Options). Render props delegate rendering to the parent via a function child prop. Use compound components for tightly coupled UI hierarchies; use render props f

Should I use Tailwind or styled-components for my design system?

Tailwind excels for rapid prototyping and utility-first design systems with small bundle size. styled-components are better for dynamic styling, theming, and complex component logic in React. CSS Modules suit gradual adoption in existing codebases. Vanilla Extract offers zero-run

How do I avoid re-render cascades in large component trees?

Profile with React DevTools. Use React.memo for expensive child components, useMemo for derived values, and useCallback for stable function references. Lift state as high as necessary but no higher. Consider context splitting to avoid unnecessary context consumer re-renders.

Is Web Component Design safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.