Vercel Composition Patterns

Use when: design composable React component APIs that scale without boolean prop sprawl.

kimtth 2b80846 1.1 KB Updated

File contents

Goal: component APIs that stay flexible as features grow.

Use for:

  • components accumulating many boolean and config props
  • shared UI that each consumer needs to customize differently
  • replacing rigid components with composable ones

Workflow:

  1. Identify the variation points consumers actually need.
  2. Prefer composition (children, slots) over configuration flags.
  3. Use compound components for related, coordinated parts.
  4. Share state via context, not prop drilling.
  5. Expose render props or slots for true customization.
  6. Keep the default usage simple; advanced control opt-in.

Patterns:

  • compound components for grouped UI (Tabs, Tabs.List, Tabs.Tab)
  • context to coordinate without prop drilling
  • render props / slots for caller-controlled rendering
  • polymorphic as prop where appropriate

Rules:

  • favor children over a growing prop list
  • do not leak internal structure through booleans
  • keep each part single-purpose and replaceable
  • common case stays trivial; complexity is opt-in

kimtth/agent-skill-100-lines-or-less/tree/main/skills/vercel-composition-patterns commit 2b80846d8d

Frequently asked questions

npx skillmds@latest add kimtth/vercel-composition-patterns