--- name: generic-react-design-system description: Complete design system reference for React applications. Covers colors, typography, spacing, component patterns, glassmorphism effects, GPU-accelerated animations, and WCAG AA accessibility. Use when implementing UI, choosing colors, applying spacing, creating components, or ensuring brand consistency. --- # React Design System Design system patterns for React/TypeScript applications. **Extends:** [Generic Design System](../generic-design-system/SKILL.md) - Read base skill for color theory, typography scale, spacing system, and component states. ## Tailwind Configuration ```js // tailwind.config.js module.exports = { theme: { extend: { colors: { primary: "var(--primary)", secondary: "var(--secondary)", accent: "var(--accent)", }, spacing: { 18: "72px", }, borderRadius: { xl: "16px", }, }, }, }; ``` ### CSS Variables Setup ```css :root { /* Brand - customize per project */ --primary: #3b82f6; --primary-rgb: 59, 130, 246; --secondary: #10b981; --accent: #8b5cf6; /* Surfaces */ --background: #ffffff; --foreground: #000000; --muted: #64748b; } [data-theme="dark"] { --background: #121212; --foreground: #ffffff; } ``` ## React Component Patterns ### Button Variants ```tsx // Primary // Secondary // Ghost ``` ### Input Fields ```tsx ``` ### Cards ```tsx
{/* Card content */}
``` ### Modals with Framer Motion ```tsx {/* Modal content */} ``` ### Loading Skeleton ```tsx
``` ## Visual Effects ### Glassmorphism ```css .glass { backdrop-filter: blur(12px) saturate(180%); background: rgba(255, 255, 255, 0.8); border: 1px solid rgba(148, 163, 184, 0.25); } .glass-dark { background: rgba(255, 255, 255, 0.05); } ``` ### Shadows ```css --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.1); --shadow-medium: 0 10px 15px rgba(0, 0, 0, 0.15); --shadow-floating: 0 25px 50px rgba(0, 0, 0, 0.3); --shadow-glow: 0 0 20px rgba(var(--primary-rgb), 0.4); ``` ## Framer Motion Patterns ### Hover Lift ```tsx {/* Content */} ``` ### Page Transitions ```tsx {/* Page content */} ``` ### Stagger Children ```tsx const container = { hidden: { opacity: 0 }, show: { opacity: 1, transition: { staggerChildren: 0.1 }, }, }; const item = { hidden: { opacity: 0, y: 20 }, show: { opacity: 1, y: 0 }, }; {items.map((i) => ( ))} ; ``` ## Dark Mode Implementation ### React Context Approach ```tsx // ThemeProvider.tsx const ThemeContext = createContext<{ theme: "light" | "dark"; toggle: () => void; }>({ theme: "light", toggle: () => {} }); export function ThemeProvider({ children }: { children: ReactNode }) { const [theme, setTheme] = useState<"light" | "dark">("light"); useEffect(() => { document.documentElement.dataset.theme = theme; }, [theme]); return ( setTheme((t) => (t === "light" ? "dark" : "light")), }} > {children} ); } ``` ### System Preference Detection ```tsx useEffect(() => { const prefersDark = window.matchMedia("(prefers-color-scheme: dark)"); setTheme(prefersDark.matches ? "dark" : "light"); prefersDark.addEventListener("change", (e) => setTheme(e.matches ? "dark" : "light"), ); }, []); ``` ## Accessibility in React ### Focus States (Tailwind) ```css *:focus-visible { @apply outline-2 outline-primary outline-offset-2; } ``` ### Skip Link ```tsx Skip to content ``` ## See Also - [Generic Design System](../generic-design-system/SKILL.md) - Tokens, spacing, typography - [Design Patterns](../_shared/DESIGN_PATTERNS.md) - Atomic Design, component docs - [UX Principles](../_shared/UX_PRINCIPLES.md) - Visual hierarchy, interaction patterns