Skip to main content

Design Systems and Component APIs

A design system is not just a folder of styled components. It is a set of stable product-independent contracts for semantics, interaction, accessibility, visual language, and composition.

Start with semantics​

function Button(props) {
return <button {...props} />;
}
Native semantics provide behavior before styling begins
Semantic element
button · input · label · nav · dialog
Keyboard
expected activation
Focus
native focus behavior
Accessibility
role/name/state foundation
Forms
submission + disabled semantics

A role can change semantics; it does not recreate all native behavior for you.

Keep variant contracts intentional​

type ButtonProps = {
variant?: 'primary' | 'secondary' | 'danger';
size?: 'sm' | 'md' | 'lg';
};
Should this become a component prop?
It represents a stable supported product/design variantExpose an intentional prop
It is normal native element behaviorReuse native prop types
It is arbitrary visual configurationPrefer composition/tokens instead of prop explosion
It creates contradictory combinationsModel mutually exclusive variants explicitly

Avoid boolean matrices such as primary, danger, outlined, blue, and large when those combinations do not form a coherent public contract.

Reuse native DOM contracts​

type ButtonProps = React.ComponentPropsWithoutRef<'button'> & {
variant?: 'primary' | 'secondary';
};

This preserves native disabled, type, aria-*, event, form, and data-attribute behavior.

React 19 also supports receiving ref as a normal prop in function components:

type InputProps = React.ComponentPropsWithoutRef<'input'> & {
ref?: React.Ref<HTMLInputElement>;
};

function Input({ ref, ...props }: InputProps) {
return <input ref={ref} {...props} />;
}

Composition beats configuration when structure varies​

Choose who owns structure
Configured component
Library owns structure; caller fills predefined fields
Composable primitive
Library owns contracts; product owns composition
<Card>
<Card.Header>
<Card.Title>Revenue</Card.Title>
<Card.Description>Last 30 days</Card.Description>
</Card.Header>
<Card.Content><RevenueChart /></Card.Content>
<Card.Footer>Updated now</Card.Footer>
</Card>

Use configuration for genuinely fixed structure. Use composition when callers need meaningful structural freedom.

Compound components coordinate one interaction model​

Compound component ownership
Tabs
public root API + internal coordination
Tabs.List
group semantics
Tabs.Trigger
focus + selected state
Tabs.Panel
content relationship

The design system owns keyboard behavior, focus management, selected state, and ARIA relationships. Product code owns the content.

Keep internal provider values private when possible; consumers should depend on the documented component API.

Controlled and uncontrolled ownership​

Who owns the value for this instance?
Parent passes value + change callbackControlled: parent is source of truth
Caller passes default value onlyUncontrolled: component owns state
<Dialog open={open} onOpenChange={setOpen} />
<Dialog defaultOpen />

Do not switch ownership modes accidentally during the same component lifetime.

Events should match the abstraction level​

DOM wrapper
Preserve native event contracts when callers need them
Higher-level primitive
Prefer domain events such as onOpenChange or onValueChange

A Select consumer often cares that the selected value changed, not which DOM event produced it.

Prop merging is part of correctness​

Do not swallow consumer handlers:

function Button({ onClick, ...props }) {
function handleClick(event) {
trackClick();
onClick?.(event);
}

return <button {...props} onClick={handleClick} />;
}

Also decide deliberately how className, style, IDs, ARIA props, and event cancellation are merged. The order of prop spreading can change the public contract.

Accessibility belongs in the primitive contract​

A reusable interaction primitive owns more than appearance
Semantics
role · name · state · relationships
Interaction
keyboard · pointer · focus · dismissal
Composition
slots · children · controlled state
DOM contract
native props · refs · data attributes
Visual contract
tokens · variants · responsive behavior
Quality
tests · docs · migration notes

Types can enforce props; they cannot by themselves guarantee keyboard semantics or focus behavior.

Keep product state out of the design system​

Design system vs product ownership
Design system
Dialog behavior · Button semantics · tokens · form primitives
Product feature
Billing cancellation · checkout workflow · permissions

A generic Dialog is infrastructure. EnterpriseBillingCancellationDialog is usually product behavior and should remain in the feature layer.

Headless vs styled APIs​

Headless primitives can expose robust behavior while leaving visual composition to a product or design layer. Styled primitives can encode visual policy directly.

How much should the primitive own?
Many brands/presentations reuse one complex interaction modelHeadless behavior can be valuable
One product needs a stable visual systemStyled semantic primitives reduce repetition
Business rules differ between usagesKeep those rules outside the primitive

Design-system change lifecycle​

1Identify stable need
2Design semantic API
3Implement interaction + a11y
4Test contracts
5Document usage
6Version + migrate safely

A good design-system API is hard to misuse, easy to compose, accessible by default, and stable enough that many teams can depend on it without freezing its internals forever.