--- id: wiki-2026-0508-확장-가능한-스타일-시스템 title: 확장 가능한 스타일 시스템 category: 10_Wiki/Topics status: verified canonical_id: self aliases: [Scalable Style System, Design Token System] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [frontend, design-system, css, design-tokens, theming] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: typescript framework: react --- # 확장 가능한 스타일 시스템 ## 매 한 줄 > **"매 design token 의 single source of truth 의 의 distill 한 이후, 매 platform-agnostic transform 의 cascade"**. 매 2026 modern style system 의 W3C Design Tokens (DTCG) format + CSS Cascade Layers + Tailwind v4 oxide engine 의 combine — 매 token 의 JSON 의 author 한 이후, 매 web/iOS/Android/Figma 의 의 sync. ## 매 핵심 ### 매 layered architecture - **Layer 0 — Primitives**: raw values (`#0066ff`, `16px`, `1.5`). - **Layer 1 — Semantic**: role-based aliases (`color.text.primary`, `space.gutter`). - **Layer 2 — Component**: component-scoped (`button.bg.hover`). - **Layer 3 — Theme**: light/dark/brand variants 의 swap layer. ### 매 핵심 capability - **Token-driven**: 매 raw CSS literal 의 X — 매 token reference 의 only. - **Multi-platform export**: Style Dictionary / Terrazzo 의 web/iOS/Android/Figma 의 generate. - **Runtime theming**: CSS custom properties 의 cascade — 매 theme swap 의 zero-rebuild. - **Type safety**: 매 token name 의 TypeScript autocomplete 의 enforce. - **Cascade Layers**: `@layer reset, tokens, components, utilities` — 매 specificity war 의 elim. ### 매 응용 1. Design system at scale (Material 3, IBM Carbon, Salesforce Lightning). 2. Multi-brand SaaS (1 codebase, N tenants). 3. Dark/light mode + high-contrast accessibility. 4. Cross-platform app (web + RN) 의 shared token. 5. AI-generated theme (LLM 의 brand color 의 variation 의 emit). ## 💻 패턴 ### Design Tokens (DTCG format) ```json // tokens/color.json — W3C Design Tokens Community Group spec { "color": { "brand": { "primary": { "$value": "#0066ff", "$type": "color" }, "accent": { "$value": "#ff3366", "$type": "color" } }, "text": { "primary": { "$value": "{color.gray.900}", "$type": "color" }, "secondary": { "$value": "{color.gray.600}", "$type": "color" } } } } ``` ### Style Dictionary build (multi-platform export) ```javascript // style-dictionary.config.js export default { source: ['tokens/**/*.json'], platforms: { css: { transformGroup: 'css', buildPath: 'dist/css/', files: [{ destination: 'tokens.css', format: 'css/variables' }] }, ts: { transformGroup: 'js', buildPath: 'dist/ts/', files: [{ destination: 'tokens.ts', format: 'javascript/es6' }] }, ios: { transformGroup: 'ios-swift', buildPath: 'dist/ios/', files: [{ destination: 'Tokens.swift', format: 'ios-swift/class.swift' }] } } }; ``` ### CSS Cascade Layers (specificity hygiene) ```css /* app.css */ @layer reset, tokens, base, components, utilities; @layer tokens { :root { --color-brand-primary: #0066ff; --space-md: 1rem; } [data-theme="dark"] { --color-text-primary: #f5f5f5; } } @layer components { .button { background: var(--color-brand-primary); padding: var(--space-md); } } @layer utilities { .text-center { text-align: center; } } ``` ### Tailwind v4 (oxide engine, CSS-first config) ```css /* app.css — Tailwind 4.0+ */ @import "tailwindcss"; @theme { --color-brand-primary: #0066ff; --spacing-gutter: 1.5rem; --font-display: "Inter Variable", sans-serif; } /* 매 utility 의 자동 generate: bg-brand-primary, p-gutter, font-display */ ``` ### Type-safe token access (TS + CSS vars) ```typescript // tokens.ts — auto-generated export const tokens = { color: { brand: { primary: 'var(--color-brand-primary)' }, text: { primary: 'var(--color-text-primary)' } }, space: { md: 'var(--space-md)' } } as const; // usage import { tokens } from './tokens'; const Button = styled.button` background: ${tokens.color.brand.primary}; padding: ${tokens.space.md}; `; ``` ### Runtime theme swap ```typescript function ThemeToggle() { const [theme, setTheme] = useState<'light' | 'dark'>('light'); useEffect(() => { document.documentElement.dataset.theme = theme; }, [theme]); return ; } // CSS: [data-theme="dark"] { --color-text-primary: #fff; } // 매 zero re-render — 매 CSS cascade 의 instant. ``` ### Component recipe (CVA pattern) ```typescript import { cva } from 'class-variance-authority'; export const button = cva('button-base', { variants: { intent: { primary: 'bg-brand-primary text-white', secondary: 'bg-gray-100 text-gray-900', danger: 'bg-red-600 text-white' }, size: { sm: 'px-2 py-1 text-sm', md: 'px-4 py-2', lg: 'px-6 py-3 text-lg' } }, defaultVariants: { intent: 'primary', size: 'md' } }); ``` ### Multi-tenant brand swap ```typescript // 매 tenant 의 own token override function loadTenantTheme(tenantId: string) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = `/themes/${tenantId}.css`; document.head.appendChild(link); } // /themes/acme.css → :root { --color-brand-primary: #ff8800; } ``` ## 매 결정 기준 | 상황 | Approach | |---|---| | Solo / small project | Tailwind v4 `@theme` only | | Multi-platform (web+iOS+Android) | DTCG tokens + Style Dictionary | | Multi-brand SaaS | CSS vars + tenant theme file | | Complex design system | DTCG + Cascade Layers + CVA | | Figma-synced | Tokens Studio plugin + DTCG export | **기본값**: DTCG JSON + Style Dictionary + Tailwind v4 + CSS Cascade Layers. ## 🔗 Graph - 부모: [[Design-System]] · [[CSS Architecture]] - 변형: [[Tailwind CSS]] · [[CSS_Architecture_and_Styling|CSS-in-JS]] - 응용: [[Theming]] · [[Dark-Mode]] - Adjacent: [[Design-Tokens]] · [[Accessibility (A11y)|Accessibility]] ## 🤖 LLM 활용 **언제**: 매 token rename refactor (1 source → N platform 의 propagate); 매 brand variant 의 LLM 의 generate ("매 corporate / playful / luxury 의 3 palette"); 매 a11y contrast 의 audit. **언제 X**: 매 final color picking 의 designer / brand 의 final call — LLM 의 raw suggestion 의 X canonical. ## ❌ 안티패턴 - **Magic number**: 매 raw `padding: 13px` — token 의 X. - **Tight component coupling**: button 의 `#0066ff` 의 hardcode — theme swap 의 die. - **Over-tokenization**: 매 every value 의 token — 매 friction 의 increase. - **Specificity war**: `!important` 의 spam — cascade layer 의 use. - **Ad-hoc dark mode**: 매 component 의 매 own dark logic — 매 token level 의 push. ## 🧪 검증 / 중복 - Verified (W3C DTCG spec; Tailwind v4 docs; Material 3 token system; Salesforce Lightning Design System). - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — DTCG + Tailwind v4 + Cascade Layers patterns 추가 |