Files
2nd/10_Wiki/Topics/Frontend/디자인 시스템 구축.md
T
2026-05-10 22:08:15 +09:00

7.7 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
Design System
Component Library
UI Kit
Design Tokens
none A 0.9 applied
frontend
design-system
components
tokens
storybook
2026-05-10 pending
language framework
typescript react

디자인 시스템 구축

매 한 줄

"매 product 가 아닌 product 를 만드는 platform". Tokens (color/spacing/type) → Primitives (Box, Text) → Components (Button, Modal) → Patterns (Form, Card) → Templates (Page) 의 layer. 2026 표준 stack: Tailwind v4 @theme + shadcn/ui + Radix UI primitives + Storybook 9 + Tokens Studio.

매 핵심

매 layer 구조

  1. Tokens: design primitives — color, spacing, type, radii, shadow, motion. CSS variable / JSON.
  2. Primitives (headless): Radix UI / Ariakit — accessibility 보장, unstyled.
  3. Components: tokens + primitives → branded — Button, Input, Dialog.
  4. Patterns: composed components — DataTable, Form, Wizard.
  5. Templates / Pages: full layouts.

매 핵심 결정

  • Headless vs styled: Radix (headless) + own styles → flex 좋음. Material UI (styled) → 빠른 시작.
  • Distribution: NPM package (@acme/ui) vs copy-paste (shadcn/ui).
  • Theme: light/dark/brand variants — CSS variable 가 표준.
  • A11y: 매 Radix/Ariakit 사용으로 무료 — 매 직접 구현 X.

매 응용

  1. Multi-product company (Atlassian, Shopify Polaris, IBM Carbon).
  2. Open source DS (shadcn/ui, Material UI, Mantine).
  3. Internal admin tool DS.
  4. Marketing + app split (display 강조 + utility).

💻 패턴

Token foundation (Tailwind v4 @theme)

@import "tailwindcss";

@theme {
  --color-bg:        oklch(1 0 0);
  --color-fg:        oklch(0.2 0 0);
  --color-primary:   oklch(0.7 0.2 250);
  --color-danger:    oklch(0.65 0.25 25);

  --spacing: 0.25rem; /* base unit */

  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;

  --font-sans: 'Inter Variable', system-ui;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.05);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.1);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 매 dark theme */
@media (prefers-color-scheme: dark) {
  @theme {
    --color-bg: oklch(0.15 0 0);
    --color-fg: oklch(0.95 0 0);
  }
}

Headless primitive + style (shadcn/ui pattern)

// components/ui/dialog.tsx
import * as DialogPrimitive from '@radix-ui/react-dialog';
import { cn } from '@/lib/cn';

export const Dialog = DialogPrimitive.Root;
export const DialogTrigger = DialogPrimitive.Trigger;

export const DialogContent = forwardRef<HTMLDivElement, DialogPrimitive.DialogContentProps>(
  ({ className, children, ...props }, ref) => (
    <DialogPrimitive.Portal>
      <DialogPrimitive.Overlay className="fixed inset-0 bg-black/50 backdrop-blur" />
      <DialogPrimitive.Content
        ref={ref}
        className={cn(
          'fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2',
          'rounded-lg bg-bg p-6 shadow-md',
          className
        )}
        {...props}
      >
        {children}
      </DialogPrimitive.Content>
    </DialogPrimitive.Portal>
  )
);

Variant API (cva / tailwind-variants)

import { cva, type VariantProps } from 'class-variance-authority';

const button = cva('inline-flex items-center rounded-md font-medium transition', {
  variants: {
    variant: {
      primary: 'bg-primary text-white hover:opacity-90',
      ghost: 'hover:bg-fg/5',
      danger: 'bg-danger text-white',
    },
    size: {
      sm: 'h-8 px-3 text-sm',
      md: 'h-10 px-4 text-base',
      lg: 'h-12 px-6 text-lg',
    },
  },
  defaultVariants: { variant: 'primary', size: 'md' },
});

export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof button> {}
export const Button = ({ className, variant, size, ...props }: ButtonProps) =>
  <button className={button({ variant, size, className })} {...props} />;

Storybook 9 setup

// Button.stories.tsx
import type { Meta, StoryObj } from '@storybook/react';
import { Button } from './Button';

const meta: Meta<typeof Button> = {
  component: Button,
  args: { children: 'Click me' },
  argTypes: {
    variant: { control: 'select', options: ['primary', 'ghost', 'danger'] },
    size: { control: 'radio', options: ['sm', 'md', 'lg'] },
  },
};
export default meta;
export const Primary: StoryObj<typeof Button> = { args: { variant: 'primary' } };
export const Danger: StoryObj<typeof Button> = { args: { variant: 'danger' } };

Visual regression with Chromatic

npx chromatic --project-token=$CHROMATIC_TOKEN
# 매 every PR 마다 every story screenshot diff.

A11y testing (axe-core)

// .storybook/preview.ts
import { withA11y } from '@storybook/addon-a11y';
export const decorators = [withA11y];

Theme provider (multi-brand)

function ThemeProvider({ brand, children }: { brand: 'acme' | 'partner', children: ReactNode }) {
  return <div data-brand={brand}>{children}</div>;
}
[data-brand="acme"]    { --color-primary: oklch(0.7 0.2 250); }
[data-brand="partner"] { --color-primary: oklch(0.65 0.18 30); }

Documentation (Storybook MDX)

import { Meta, Canvas } from '@storybook/blocks';
import * as ButtonStories from './Button.stories';

<Meta of={ButtonStories} />

# Button
Primary action element.

## Usage
<Canvas of={ButtonStories.Primary} />

### When to use
- 매 form submit
- 매 destructive action — `variant="danger"`

shadcn/ui CLI (copy-paste distribution)

npx shadcn@latest add button dialog form
# 매 직접 components/ui/ 에 source 가 들어옴 — 매 자유롭게 수정.

매 결정 기준

상황 Approach
Startup MVP shadcn/ui copy-paste — quick.
Multi-product company own DS as @acme/ui package.
Enterprise Material UI / Carbon / Polaris fork.
A11y critical Radix / Ariakit primitives 필수.
Design ↔ code sync Figma + Tokens Studio + Style Dictionary.
Visual QA Storybook + Chromatic.

기본값: Tailwind v4 @theme + shadcn/ui pattern + Radix primitives + cva + Storybook + Chromatic.

🔗 Graph

🤖 LLM 활용

언제: 5+ devs, 3+ products, brand consistency 필요, A11y compliance. 언제 X: 매 single landing page, 매 prototype, single dev (premade DS 로 충분).

안티패턴

  • Inventing primitives: 매 own dropdown / dialog 만듦 — Radix 사용. A11y 함정 많음.
  • Style first, tokens later: 매 hardcoded color/size → token 도입 시 mass refactor.
  • Component sprawl: button 변형 50개 — variant API 로 정리.
  • No Storybook: design review 시 매 dev branch 띄워야 — 비효율.
  • Forking instead of extending: shadcn 매 update 누락. wrapper 로 extend.
  • Light-only: dark mode 나중에 → token 처음부터 분리.
  • No CHANGELOG: 매 breaking change silent — Changeset.

🧪 검증 / 중복

  • Weighted by industry adoption (Polaris, Carbon, Material UI, shadcn/ui).
  • Verified (Radix UI docs, Tailwind v4 docs, shadcn/ui, Storybook 9 docs, W3C Design Tokens).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — Tailwind v4 + shadcn/ui + Radix + Storybook 9 stack