prototype
MAmattpocock/skills337k4,978 new stars in the last 7 days
Design React component APIs that are composable, predictable, and hard to misuse — composition over configuration, compound components, controlled/uncontrolled state, and sensible props. Use when creating or refactoring React components, designing a component library, reviewing a props API, or deciding how a component should expose customization. Triggers on: component API, props design, compound components, composition, configuration props, controlled, uncontrolled, defaultValue, asChild, Slot, render props, forwardRef, ref forwarding, variants, className override, design system components, reusable components, component library, Radix, shadcn, prop drilling, boolean props, slots, children, context.
A component API is a contract. Good ones make the common case a one-liner and the uncommon case possible without forking. The failure modes are always the same: too rigid (users fork or hack around you) or too configurable (30 props nobody can hold in their head). Reach for composition before configuration, name things the way the platform names them, and support both controlled and uncontrolled state when state is involved.
| Topic | Where |
|---|---|
| Core API decisions (composition, compound, props, state) | This file |
| Implementation patterns (context, controlled/uncontrolled, asChild, refs, slots, file structure) | implementation.md |
Expose structure as JSX children, not configuration objects:
// Good - composable
<Card>
<CardHeader>
<CardTitle>Title</CardTitle>
<CardDescription>Description</CardDescription>
</CardHeader>
<CardContent>Content here</CardContent>
<CardFooter>
<Button>Action</Button>
</CardFooter>
</Card>
// Bad - configuration object
<Card
header={{ title: "Title", description: "Description" }}
content="Content here"
footer={{ actions: [{ label: "Action", onClick: () => {} }] }}
/>
When a component has multiple related parts sharing implicit state, split it into compound components instead of prop-drilling everything through one root:
// Good - compound components
<Dialog>
<Dialog.Trigger>Open</Dialog.Trigger>
<Dialog.Content>
<Dialog.Title>Are you sure?</Dialog.Title>
<Dialog.Description>This action cannot be undone.</Dialog.Description>
<Dialog.Close>Cancel</Dialog.Close>
</Dialog.Content>
</Dialog>
// Bad - prop drilling everything
<Dialog
trigger="Open"
title="Are you sure?"
description="This action cannot be undone."
closeText="Cancel"
/>
Use compound components when:
Don't use them when:
Share the implicit state through React context — the root provides, the parts consume. Implementation in implementation.md.
Too little customization and users fork your component or add hacky workarounds. Too much and the API becomes confusing and a maintenance nightmare. Aim for the middle:
// Too rigid - no customization
<Button>Click me</Button>
// Too flexible - overwhelming API
<Button
backgroundColor="#000"
hoverBackgroundColor="#333"
activeBackgroundColor="#111"
borderRadius={4}
paddingX={16}
paddingY={8}
fontSize={14}
fontWeight={500}
// ... 30 more props
>
Click me
</Button>
// Just right - variants + escape hatch
<Button variant="primary" size="md" className="custom-override">
Click me
</Button>
Layer customization in this order:
primary, secondary, destructive)sm, md, lg)When implementing variants, express the styles in the project's existing styling system (Tailwind, CSS Modules, vanilla-extract, styled-components — whatever the codebase already uses). Don't impose a new one.
Be consistent across every component, mirror HTML where possible:
// Good - consistent patterns
<Input disabled />
<Button disabled />
<Select disabled />
// Bad - inconsistent
<Input disabled />
<Button isDisabled />
<Select readonly />
Boolean props get positive names — never double negatives:
// Good
<Input disabled />
<Modal open />
// Bad
<Input notEnabled />
<Modal isNotClosed />
Event handlers are prefixed with on:
// Good
<Input onChange={} onBlur={} />
<Dialog onOpenChange={} onClose={} />
// Bad
<Input handleChange={} blurHandler={} />
Any stateful component should work both ways — internal state by default, external state when the consumer needs it:
// Uncontrolled
<Input defaultValue="hello" />
// Controlled
<Input value={value} onChange={setValue} />
Full dual-mode implementation in implementation.md.
{...props}) so aria-*, data-testid, and other HTML attributes pass through.variant = "primary", size = "md", and type = "button" (not "submit" — the safer default).Code for all three in implementation.md.
asChild patternLet consumers swap the rendered element while keeping the behavior and styles:
// Render as button (default)
<Button>Click me</Button>
// Render as link
<Button asChild>
<a href="/page">Click me</a>
</Button>
// Render as Next.js Link
<Button asChild>
<Link href="/page">Click me</Link>
</Button>
// Simple - use children
<Card>
<CardContent />
</Card>
// Complex with data - render prop
<List
items={users}
renderItem={(user) => <UserCard user={user} />}
/>
For optional sections that take arbitrary JSX, use slot props (header={<h2>Title</h2>}) — see the slot pattern in implementation.md.
leftIcon, rightIcon, iconSpacing, iconSize... just use children: <Button><Icon /> Click <Arrow /></Button>.<Button primary large rounded> invites invalid combinations. Use <Button variant="primary" size="lg" radius="full">.{...props} breaks aria-*, data-*, and testing attributes.className escape hatch; no style-prop explosionvalue/onChange and defaultValuetype="button" defaultMAmattpocock/skills337k4,978 new stars in the last 7 days
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
FIfirecrawl/firecrawl215k5,595 new stars in the last 7 days
ANanthropics/skills203k3,265 new stars in the last 7 days
Set visual direction and typography for UI, avoiding templated defaults.
ANanthropics/skills203k3,265 new stars in the last 7 days
Build complex HTML artifacts with React, Tailwind CSS, state management and routing.
ANanthropics/skills203k3,265 new stars in the last 7 days