The Design System Engineer builds the shared component library and token system that keeps a product visually consistent as it scales. A design system's value is proportional to its adoption - systems that are hard to use or don't cover common patterns get bypassed. Every component must be easier to use correctly than to build from scratch.
Token Architecture
// tokens/index.ts - exported from the design system package
export const tokens = {
color: {
// Primitive
blue: { 50: '#eff6ff', 500: '#3b82f6', 900: '#1e3a8a' },
red: { 50: '#fef2f2', 500: '#ef4444', 900: '#7f1d1d' },
// Semantic (reference primitives)
primary: '#3b82f6',
danger: '#ef4444',
text: { primary: '#111827', secondary: '#6b7280', disabled: '#d1d5db' },
surface: { default: '#ffffff', subtle: '#f9fafb', elevated: '#ffffff' },
border: { default: '#e5e7eb', strong: '#9ca3af' },
},
spacing: {
0: '0', 1: '0.25rem', 2: '0.5rem', 3: '0.75rem',
4: '1rem', 6: '1.5rem', 8: '2rem', 12: '3rem', 16: '4rem',
},
radius: { none: '0', sm: '4px', md: '8px', lg: '12px', full: '9999px' },
shadow: {
sm: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
md: '0 4px 6px -1px rgb(0 0 0 / 0.1)',
lg: '0 10px 15px -3px rgb(0 0 0 / 0.1)',
},
} as const;
Component API Design
// Principle: components should have opinionated defaults and explicit variants
// Never expose too many props - complexity leaks from component to consumer
interface ButtonProps {
// Variant (required pattern - not optional styling)
variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
size?: 'sm' | 'md' | 'lg';
// State
loading?: boolean;
disabled?: boolean;
// Content
children: React.ReactNode;
leftIcon?: React.ReactNode;
// Passthrough for flexibility
onClick?: React.MouseEventHandler<HTMLButtonElement>;
type?: 'button' | 'submit' | 'reset';
'aria-label'?: string;
// AVOID: individual style props (color, padding, fontSize)
// They bypass the design system and create inconsistency
}
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ variant = 'primary', size = 'md', loading, disabled, children, ...props }, ref) => {
return (
<button
ref={ref}
disabled={disabled || loading}
aria-busy={loading}
className={cn(styles.button, styles[variant], styles[size])}
{...props}
>
{loading ? <Spinner /> : children}
</button>
);
}
);
Storybook Story Requirements
- Every component has at minimum: Default, AllVariants, Loading/Disabled, and DarkMode stories
- Stories use
playfunctions to test interactive behaviour (Chromatic tests run these) - Every story includes
parameters.a11y- Storybook accessibility addon runs axe on every story - Document props with JSDoc comments - Storybook autodocs generates the props table from them
- Version the component library with changesets; breaking API changes require major version bump