--- name: frontend-design-systems description: Systematic approach to building consistent, maintainable frontend UI components with design systems and component libraries license: MIT metadata: adapted-by: ai-skills category: frontend-development --- # Frontend Design Systems Build consistent, scalable UI components with systematic design patterns. ## Design Token System ### Color Tokens ```typescript // tokens/colors.ts export const colors = { primary: { 50: '#e3f2fd', 100: '#bbdefb', 500: '#2196f3', 900: '#0d47a1', }, neutral: { 50: '#fafafa', 100: '#f5f5f5', 500: '#9e9e9e', 900: '#212121', }, semantic: { success: '#4caf50', warning: '#ff9800', error: '#f44336', info: '#2196f3', } }; ``` ### Spacing Scale ```typescript export const spacing = { xs: '0.25rem', // 4px sm: '0.5rem', // 8px md: '1rem', // 16px lg: '1.5rem', // 24px xl: '2rem', // 32px '2xl': '3rem', // 48px }; ``` ### Typography System ```typescript export const typography = { fontFamily: { sans: ['Inter', 'system-ui', 'sans-serif'], mono: ['Fira Code', 'monospace'], }, fontSize: { xs: ['0.75rem', { lineHeight: '1rem' }], sm: ['0.875rem', { lineHeight: '1.25rem' }], base: ['1rem', { lineHeight: '1.5rem' }], lg: ['1.125rem', { lineHeight: '1.75rem' }], xl: ['1.25rem', { lineHeight: '1.75rem' }], }, fontWeight: { normal: '400', medium: '500', semibold: '600', bold: '700', } }; ``` ## Component Patterns ### Base Button Component ```typescript interface ButtonProps { variant?: 'primary' | 'secondary' | 'outline'; size?: 'sm' | 'md' | 'lg'; disabled?: boolean; loading?: boolean; children: React.ReactNode; onClick?: () => void; } export function Button({ variant = 'primary', size = 'md', disabled = false, loading = false, children, onClick, }: ButtonProps) { const variants = { primary: 'bg-primary-500 text-white hover:bg-primary-600', secondary: 'bg-neutral-200 text-neutral-900 hover:bg-neutral-300', outline: 'border-2 border-primary-500 text-primary-500 hover:bg-primary-50', }; const sizes = { sm: 'px-3 py-1.5 text-sm', md: 'px-4 py-2 text-base', lg: 'px-6 py-3 text-lg', }; return ( ); } ``` ### Compound Components ```typescript // Card compound component pattern export function Card({ children }: { children: React.ReactNode }) { return