Design Systems Best Practices
Guidelines for creating and maintaining design systems that ensure visual consistency, accessibility compliance, and scalable component architecture across digital products.
Workflow: Setting Up a Design System
- Audit existing UI — Inventory current components, colors, typography, and spacing across the product to identify inconsistencies and reusable patterns.
- Define design tokens — Establish primitive tokens (colors, spacing, typography, shadows) as CSS custom properties or a token format (e.g., Style Dictionary) that serves as the single source of truth.
- Build foundational components — Create atomic components (Button, Input, Text, Icon) that consume design tokens and expose a clear props API with TypeScript types.
- Compose patterns and layouts — Assemble atomic components into higher-order patterns (forms, cards, navigation) with documented usage guidelines.
- Set up documentation and Storybook — Configure Storybook with stories for every component variant, state, and accessibility annotation. Publish as a living style guide.
- Integrate testing and governance — Add visual regression tests (e.g., Chromatic), accessibility linting (e.g., axe-core), and a contribution/review process for new components.
- Ship and iterate — Publish the library as a versioned package, gather consumer feedback, and run regular accessibility and performance audits.
Foundation Elements
Color System
- Define primary, secondary, and accent colors
- Include semantic colors for success, warning, error, info states
- Ensure all color combinations meet WCAG contrast requirements
- Document color usage guidelines and contexts
- Provide light and dark mode variants
Typography
- Establish a type scale with consistent ratios
- Define font families for headings and body text
- Set line heights and letter spacing standards
- Document font weights and their usage
- Ensure readability across screen sizes
Spacing System
- Define consistent spacing scale (4px, 8px, 16px, 24px, etc.)
- Create layout primitives for common patterns
- Document margin and padding conventions
- Ensure responsive spacing behavior
- Use CSS custom properties for maintainability
Icons and Imagery
- Maintain consistent icon style and sizing
- Define icon grid and stroke weights
- Document icon naming conventions
- Optimize assets for web performance
- Provide multiple formats when needed (SVG, PNG)
Component Architecture
Component Structure
- Create atomic, reusable components
- Define clear component APIs (props/attributes)
- Document variants and states
- Ensure components are accessible by default
- Provide clear naming conventions
Component States
- Default state
- Hover state
- Focus state (keyboard navigation)
- Active/pressed state
- Disabled state
- Loading state
- Error state
Component Variants
- Size variants (small, medium, large)
- Color/theme variants
- Layout variants
- Contextual variants
Accessibility Requirements
- Follow WCAG 2.1 AA guidelines minimum
- Use semantic HTML elements
- Provide ARIA labels where needed
- Ensure keyboard navigation
- Test with screen readers
- Maintain color contrast ratios
- Support reduced motion preferences
Documentation Standards
Component Documentation
- Purpose and use cases
- Props/API reference
- Code examples
- Do's and don'ts
- Accessibility notes
- Related components
Pattern Documentation
- When to use
- Anatomy breakdown
- Behavior specifications
- Responsive considerations
- Edge cases
Implementation Guidelines
CSS Architecture
- Use CSS custom properties for tokens
- Implement utility classes for common patterns
- Follow BEM or similar naming convention
- Ensure specificity is manageable
- Support theming and customization
Component Libraries
- Framework-agnostic when possible
- Tree-shakeable exports
- TypeScript support
- Comprehensive test coverage
- Storybook integration
Governance
Contribution Guidelines
- How to propose new components
- Review and approval process
- Versioning strategy
- Breaking change policy
- Deprecation process
Maintenance
- Regular accessibility audits
- Performance monitoring
- Browser compatibility testing
- Documentation updates
- Community feedback incorporation
Design Tokens
Token Categories
- Colors
- Typography (font sizes, weights, line heights)
- Spacing
- Border radius
- Shadows
- Breakpoints
- Animation durations
- Z-index values
Token Implementation
:root {
/* Colors */
--color-primary-500: #0066cc;
--color-neutral-100: #f5f5f5;
/* Spacing */
--space-1: 4px;
--space-2: 8px;
--space-4: 16px;
/* Typography */
--font-size-sm: 0.875rem;
--font-size-base: 1rem;
--font-size-lg: 1.125rem;
/* Shadows */
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}
Example: React Button Component Using Design Tokens
import React from "react";
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: "primary" | "secondary" | "danger";
size?: "sm" | "md" | "lg";
loading?: boolean;
}
const sizeStyles: Record<string, React.CSSProperties> = {
sm: { padding: "var(--space-1) var(--space-2)", fontSize: "var(--font-size-sm)" },
md: { padding: "var(--space-2) var(--space-4)", fontSize: "var(--font-size-base)" },
lg: { padding: "var(--space-3) var(--space-6)", fontSize: "var(--font-size-lg)" },
};
export const Button: React.FC<ButtonProps> = ({
variant = "primary",
size = "md",
loading = false,
disabled,
children,
...props
}) => (
<button
style={{
...sizeStyles[size],
backgroundColor: `var(--color-${variant}-500)`,
color: "var(--color-neutral-100)",
borderRadius: "var(--radius-md)",
boxShadow: "var(--shadow-sm)",
cursor: disabled || loading ? "not-allowed" : "pointer",
opacity: disabled ? 0.5 : 1,
}}
disabled={disabled || loading}
aria-busy={loading}
{...props}
>
{loading ? "Loading…" : children}
</button>
);
Example: Storybook Configuration
// .storybook/preview.ts
import type { Preview } from "@storybook/react";
import "../src/tokens.css"; // import design tokens globally
const preview: Preview = {
parameters: {
a11y: { element: "#storybook-root" },
backgrounds: {
default: "light",
values: [
{ name: "light", value: "#ffffff" },
{ name: "dark", value: "#1a1a1a" },
],
},
},
};
export default preview;
Quality Assurance
- Visual regression testing
- Accessibility automated testing
- Cross-browser testing
- Performance benchmarking
- Component unit testing
- Integration testing
When evolving the design system, validate changes against WCAG 2.1 AA, run visual regression tests, and ensure token updates propagate correctly across all consuming applications.
1---2name: design-systems3description: "Comprehensive design system guidelines for building consistent, accessible, and scalable component libraries. Use when creating design tokens, building component libraries, implementing design systems, setting up theming architecture, or establishing UI governance processes."4metadata:5 maintainer: Mindrally6 source: https://skillmd.com/skills/mindrally/design-systems7 upstream: https://github.com/Mindrally/skills8---910# Design Systems Best Practices1112Guidelines for creating and maintaining design systems that ensure visual consistency, accessibility compliance, and scalable component architecture across digital products.1314## Workflow: Setting Up a Design System15161. **Audit existing UI** — Inventory current components, colors, typography, and spacing across the product to identify inconsistencies and reusable patterns.172. **Define design tokens** — Establish primitive tokens (colors, spacing, typography, shadows) as CSS custom properties or a token format (e.g., Style Dictionary) that serves as the single source of truth.183. **Build foundational components** — Create atomic components (Button, Input, Text, Icon) that consume design tokens and expose a clear props API with TypeScript types.194. **Compose patterns and layouts** — Assemble atomic components into higher-order patterns (forms, cards, navigation) with documented usage guidelines.205. **Set up documentation and Storybook** — Configure Storybook with stories for every component variant, state, and accessibility annotation. Publish as a living style guide.216. **Integrate testing and governance** — Add visual regression tests (e.g., Chromatic), accessibility linting (e.g., axe-core), and a contribution/review process for new components.227. **Ship and iterate** — Publish the library as a versioned package, gather consumer feedback, and run regular accessibility and performance audits.2324## Foundation Elements2526### Color System2728- Define primary, secondary, and accent colors29- Include semantic colors for success, warning, error, info states30- Ensure all color combinations meet WCAG contrast requirements31- Document color usage guidelines and contexts32- Provide light and dark mode variants3334### Typography3536- Establish a type scale with consistent ratios37- Define font families for headings and body text38- Set line heights and letter spacing standards39- Document font weights and their usage40- Ensure readability across screen sizes4142### Spacing System4344- Define consistent spacing scale (4px, 8px, 16px, 24px, etc.)45- Create layout primitives for common patterns46- Document margin and padding conventions47- Ensure responsive spacing behavior48- Use CSS custom properties for maintainability4950### Icons and Imagery5152- Maintain consistent icon style and sizing53- Define icon grid and stroke weights54- Document icon naming conventions55- Optimize assets for web performance56- Provide multiple formats when needed (SVG, PNG)5758## Component Architecture5960### Component Structure6162- Create atomic, reusable components63- Define clear component APIs (props/attributes)64- Document variants and states65- Ensure components are accessible by default66- Provide clear naming conventions6768### Component States6970- Default state71- Hover state72- Focus state (keyboard navigation)73- Active/pressed state74- Disabled state75- Loading state76- Error state7778### Component Variants7980- Size variants (small, medium, large)81- Color/theme variants82- Layout variants83- Contextual variants8485## Accessibility Requirements8687- Follow WCAG 2.1 AA guidelines minimum88- Use semantic HTML elements89- Provide ARIA labels where needed90- Ensure keyboard navigation91- Test with screen readers92- Maintain color contrast ratios93- Support reduced motion preferences9495## Documentation Standards9697### Component Documentation9899- Purpose and use cases100- Props/API reference101- Code examples102- Do's and don'ts103- Accessibility notes104- Related components105106### Pattern Documentation107108- When to use109- Anatomy breakdown110- Behavior specifications111- Responsive considerations112- Edge cases113114## Implementation Guidelines115116### CSS Architecture117118- Use CSS custom properties for tokens119- Implement utility classes for common patterns120- Follow BEM or similar naming convention121- Ensure specificity is manageable122- Support theming and customization123124### Component Libraries125126- Framework-agnostic when possible127- Tree-shakeable exports128- TypeScript support129- Comprehensive test coverage130- Storybook integration131132## Governance133134### Contribution Guidelines135136- How to propose new components137- Review and approval process138- Versioning strategy139- Breaking change policy140- Deprecation process141142### Maintenance143144- Regular accessibility audits145- Performance monitoring146- Browser compatibility testing147- Documentation updates148- Community feedback incorporation149150## Design Tokens151152### Token Categories153154- Colors155- Typography (font sizes, weights, line heights)156- Spacing157- Border radius158- Shadows159- Breakpoints160- Animation durations161- Z-index values162163### Token Implementation164165```css166:root {167 /* Colors */168 --color-primary-500: #0066cc;169 --color-neutral-100: #f5f5f5;170171 /* Spacing */172 --space-1: 4px;173 --space-2: 8px;174 --space-4: 16px;175176 /* Typography */177 --font-size-sm: 0.875rem;178 --font-size-base: 1rem;179 --font-size-lg: 1.125rem;180181 /* Shadows */182 --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);183 --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);184}185```186187### Example: React Button Component Using Design Tokens188189```tsx190import React from "react";191192interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {193 variant?: "primary" | "secondary" | "danger";194 size?: "sm" | "md" | "lg";195 loading?: boolean;196}197198const sizeStyles: Record<string, React.CSSProperties> = {199 sm: { padding: "var(--space-1) var(--space-2)", fontSize: "var(--font-size-sm)" },200 md: { padding: "var(--space-2) var(--space-4)", fontSize: "var(--font-size-base)" },201 lg: { padding: "var(--space-3) var(--space-6)", fontSize: "var(--font-size-lg)" },202};203204export const Button: React.FC<ButtonProps> = ({205 variant = "primary",206 size = "md",207 loading = false,208 disabled,209 children,210 ...props211}) => (212 <button213 style={{214 ...sizeStyles[size],215 backgroundColor: `var(--color-${variant}-500)`,216 color: "var(--color-neutral-100)",217 borderRadius: "var(--radius-md)",218 boxShadow: "var(--shadow-sm)",219 cursor: disabled || loading ? "not-allowed" : "pointer",220 opacity: disabled ? 0.5 : 1,221 }}222 disabled={disabled || loading}223 aria-busy={loading}224 {...props}225 >226 {loading ? "Loading…" : children}227 </button>228);229```230231### Example: Storybook Configuration232233```ts234// .storybook/preview.ts235import type { Preview } from "@storybook/react";236import "../src/tokens.css"; // import design tokens globally237238const preview: Preview = {239 parameters: {240 a11y: { element: "#storybook-root" },241 backgrounds: {242 default: "light",243 values: [244 { name: "light", value: "#ffffff" },245 { name: "dark", value: "#1a1a1a" },246 ],247 },248 },249};250251export default preview;252```253254## Quality Assurance255256- Visual regression testing257- Accessibility automated testing258- Cross-browser testing259- Performance benchmarking260- Component unit testing261- Integration testing262263When evolving the design system, validate changes against WCAG 2.1 AA, run visual regression tests, and ensure token updates propagate correctly across all consuming applications.