Files
2nd/10_Wiki/Topics/AI_and_ML/확장 가능한 스타일 시스템.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

7.2 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-확장-가능한-스타일-시스템 확장 가능한 스타일 시스템 10_Wiki/Topics verified self
Scalable Style System
Design Token System
none A 0.9 applied
frontend
design-system
css
design-tokens
theming
2026-05-10 pending
language framework
typescript 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)

// 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)

// 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)

/* 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)

/* 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)

// 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

function ThemeToggle() {
  const [theme, setTheme] = useState<'light' | 'dark'>('light');
  useEffect(() => {
    document.documentElement.dataset.theme = theme;
  }, [theme]);
  return <button onClick={() => setTheme(t => t === 'light' ? 'dark' : 'light')}>
    Toggle
  </button>;
}
// CSS: [data-theme="dark"] { --color-text-primary: #fff; }
// 매 zero re-render — 매 CSS cascade 의 instant.

Component recipe (CVA pattern)

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' }
});

<button className={button({ intent: 'danger', size: 'lg' })}>Delete</button>

Multi-tenant brand swap

// 매 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

🤖 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 추가