UI Design System
Generate design tokens, create color palettes, calculate typography scales, build component systems, and prepare developer handoff documentation.
Table of Contents
-
Workflow 1: Generate Design Tokens
-
Workflow 2: Create Component System
-
Workflow 3: Responsive Design
-
Workflow 4: Developer Handoff
Trigger Terms
Use this skill when you need to:
- "generate design tokens" "create color palette" "build typography scale" "calculate spacing system" "create design system" "generate CSS variables" "export SCSS tokens" "set up component architecture" "document component library" "calculate responsive breakpoints" "prepare developer handoff" "convert brand color to palette" "check WCAG contrast" "build 8pt grid system"
Workflows
Workflow 1: Generate Design Tokens
Situation: You have a brand color and need a complete design token system.
Steps:
1. Identify brand color and style
- Brand primary color (hex format)
- Style preference:
modern |
classic | INLINECODE2
2. Generate tokens using script
CODEBLOCK0
3. Review generated categories
- Colors: primary, secondary, neutral, semantic, surface
- Typography: fontFamily, fontSize, fontWeight, lineHeight
- Spacing: 8pt grid-based scale (0-64)
- Borders: radius, width
- Shadows: none through 2xl
- Animation: duration, easing
- Breakpoints: xs through 2xl
4. Export in target format
CODEBLOCK1
5. Validate accessibility
- Check color contrast meets WCAG AA (4.5:1 normal, 3:1 large text)
- Verify semantic colors have contrast colors defined
Workflow 2: Create Component System
Situation: You need to structure a component library using design tokens.
Steps:
1. Define component hierarchy
- Atoms: Button, Input, Icon, Label, Badge
- Molecules: FormField, SearchBar, Card, ListItem
- Organisms: Header, Footer, DataTable, Modal
- Templates: DashboardLayout, AuthLayout
2. Map tokens to components
| Component | Tokens Used |
|-----------|-------------|
| Button | colors, sizing, borders, shadows, typography |
| Input | colors, sizing, borders, spacing |
| Card | colors, borders, shadows, spacing |
| Modal | colors, shadows, spacing, z-index, animation |
3. Define variant patterns
Size variants:
CODEBLOCK2
Color variants:
CODEBLOCK3
4. Document component API
- Props interface with types
- Variant options
- State handling (hover, active, focus, disabled)
- Accessibility requirements
5. Reference: See INLINECODE3
Workflow 3: Responsive Design
Situation: You need breakpoints, fluid typography, or responsive spacing.
Steps:
1. Define breakpoints
| Name | Width | Target |
|------|-------|--------|
| xs | 0 | Small phones |
| sm | 480px | Large phones |
| md | 640px | Tablets |
| lg | 768px | Small laptops |
| xl | 1024px | Desktops |
| 2xl | 1280px | Large screens |
2. Calculate fluid typography
Formula: INLINECODE4
CODEBLOCK4
Pre-calculated scales:
CODEBLOCK5
3. Set up responsive spacing
| Token | Mobile | Tablet | Desktop |
|-------|--------|--------|---------|
| --space-md | 12px | 16px | 16px |
| --space-lg | 16px | 24px | 32px |
| --space-xl | 24px | 32px | 48px |
| --space-section | 48px | 80px | 120px |
4. Reference: See INLINECODE5
Workflow 4: Developer Handoff
Situation: You need to hand off design tokens to development team.
Steps:
1. Export tokens in required formats
CODEBLOCK6
2. Prepare framework integration
React + CSS Variables:
CODEBLOCK7
Tailwind Config:
CODEBLOCK8
styled-components:
CODEBLOCK9
3. Sync with Figma
- Install Tokens Studio plugin
- Import design-tokens.json
- Tokens sync automatically with Figma styles
4. Handoff checklist
- [ ] Token files added to project
- [ ] Build pipeline configured
- [ ] Theme/CSS variables imported
- [ ] Component library aligned
- [ ] Documentation generated
5. Reference: See INLINECODE6
Tool Reference
designtoken generator.py
Generates complete design token system from brand color.
Argument Values Default Description brand_color Hex color #0066CC Primary brand color style
modern, classic, playful | modern | Design style preset |
| format | json, css, scss, summary | json | Output format |
Examples:
CODEBLOCK10
Output Categories:
Category Description Key Values colors Color palettes primary, secondary, neutral, semantic, surface typography
Font system | fontFamily, fontSize, fontWeight, lineHeight |
| spacing | 8pt grid | 0-64 scale, semantic (xs-3xl) |
| sizing | Component sizes | container, button, input, icon |
| borders | Border values | radius (per style), width |
| shadows | Shadow styles | none through 2xl, inner |
| animation | Motion tokens | duration, easing, keyframes |
| breakpoints | Responsive | xs, sm, md, lg, xl, 2xl |
| z-index | Layer system | base through notification |
Quick Reference Tables
Color Scale Generation
Step Brightness Saturation Use Case 50 95% fixed 30% Subtle backgrounds 100
95% fixed | 38% | Light backgrounds |
| 200 | 95% fixed | 46% | Hover states |
| 300 | 95% fixed | 54% | Borders |
| 400 | 95% fixed | 62% | Disabled states |
| 500 | Original | 70% | Base/default color |
| 600 | Original × 0.8 | 78% | Hover (dark) |
| 700 | Original × 0.6 | 86% | Active states |
| 800 | Original × 0.4 | 94% | Text |
| 900 | Original × 0.2 | 100% | Headings |
Typography Scale (1.25x Ratio)
Size Value Calculation xs 10px 16 ÷ 1.25² sm
13px | 16 ÷ 1.25¹ |
| base | 16px | Base |
| lg | 20px | 16 × 1.25¹ |
| xl | 25px | 16 × 1.25² |
| 2xl | 31px | 16 × 1.25³ |
| 3xl | 39px | 16 × 1.25⁴ |
| 4xl | 49px | 16 × 1.25⁵ |
| 5xl | 61px | 16 × 1.25⁶ |
WCAG Contrast Requirements
Level Normal Text Large Text AA 4.5:1 3:1 AAA
7:1 | 4.5:1 |
Large text: ≥18pt regular or ≥14pt bold
Style Presets
Aspect Modern Classic Playful Font Sans Inter Helvetica Poppins Font Mono
Fira Code | Courier | Source Code Pro |
| Radius Default | 8px | 4px | 16px |
| Shadows | Layered, subtle | Single layer | Soft, pronounced |
Knowledge Base
Detailed reference guides in references/:
File Content INLINECODE8 Color algorithms, HSV space, WCAG contrast, type scales INLINECODE9
Atomic design, naming conventions, props patterns |
|
responsive-calculations.md | Breakpoints, fluid typography, grid systems |
|
developer-handoff.md | Export formats, framework setup, Figma sync |
Validation Checklist
Token Generation
- [ ] Brand color provided in hex format [ ] Style matches project requirements [ ] All token categories generated [ ] Semantic colors include contrast values
Component System
- [ ] All sizes implemented (sm, md, lg) [ ] All variants implemented (primary, secondary, ghost) [ ] All states working (hover, active, focus, disabled) [ ] Uses only design tokens (no hardcoded values)
Accessibility
- [ ] Color contrast meets WCAG AA [ ] Focus indicators visible [ ] Touch targets ≥ 44×44px [ ] Semantic HTML elements used
Developer Handoff
- [ ] Tokens exported in required format [ ] Framework integration documented [ ] Design tool synced [ ] Component documentation complete
UI 设计系统
生成设计令牌、创建调色板、计算排版比例、构建组件系统,并准备开发者交接文档。
目录
-
工作流程 1:生成设计令牌
-
工作流程 2:创建组件系统
-
工作流程 3:响应式设计
-
工作流程 4:开发者交接
触发术语
当您需要以下内容时,请使用此技能:
- 生成设计令牌 创建调色板 构建排版比例 计算间距系统 创建设计系统 生成 CSS 变量 导出 SCSS 令牌 设置组件架构 记录组件库 计算响应式断点 准备开发者交接 将品牌色转换为调色板 检查 WCAG 对比度 构建 8pt 网格系统
工作流程
工作流程 1:生成设计令牌
场景: 您有一个品牌色,需要完整的令牌系统。
步骤:
1. 识别品牌色和风格
- 品牌主色(十六进制格式)
- 风格偏好:modern | classic | playful
2. 使用脚本生成令牌
bash
python scripts/design
token generator.py #0066CC modern json
3. 审查生成的类别
- 颜色:主色、辅色、中性色、语义色、表面色
- 排版:字体系列、字号、字重、行高
- 间距:基于 8pt 网格的比例(0-64)
- 边框:圆角、宽度
- 阴影:无到 2xl
- 动画:时长、缓动
- 断点:xs 到 2xl
4. 以目标格式导出
bash
# CSS 自定义属性
python scripts/design
token generator.py #0066CC modern css > design-tokens.css
# SCSS 变量
python scripts/designtoken generator.py #0066CC modern scss > _design-tokens.scss
# 用于 Figma/工具的 JSON
python scripts/designtoken generator.py #0066CC modern json > design-tokens.json
5. 验证可访问性
- 检查颜色对比度是否符合 WCAG AA(普通文本 4.5:1,大文本 3:1)
- 验证语义色是否定义了对比色
工作流程 2:创建组件系统
场景: 您需要使用设计令牌构建组件库结构。
步骤:
1. 定义组件层级
- 原子:按钮、输入框、图标、标签、徽章
- 分子:表单字段、搜索栏、卡片、列表项
- 有机体:页眉、页脚、数据表格、模态框
- 模板:仪表盘布局、认证布局
2. 将令牌映射到组件
| 组件 | 使用的令牌 |
|------|------------|
| 按钮 | 颜色、尺寸、边框、阴影、排版 |
| 输入框 | 颜色、尺寸、边框、间距 |
| 卡片 | 颜色、边框、阴影、间距 |
| 模态框 | 颜色、阴影、间距、z-index、动画 |
3. 定义变体模式
尺寸变体:
sm:高度 32px,内边距X 12px,字号 14px
md:高度 40px,内边距X 16px,字号 16px
lg:高度 48px,内边距X 20px,字号 18px
颜色变体:
primary:背景 primary-500,文本 white
secondary:背景 neutral-100,文本 neutral-900
ghost:背景 transparent,文本 neutral-700
4. 记录组件 API
- 带类型的 Props 接口
- 变体选项
- 状态处理(悬停、激活、聚焦、禁用)
- 可访问性要求
5. 参考: 参见 references/component-architecture.md
工作流程 3:响应式设计
场景: 您需要断点、流式排版或响应式间距。
步骤:
1. 定义断点
| 名称 | 宽度 | 目标设备 |
|------|------|----------|
| xs | 0 | 小屏手机 |
| sm | 480px | 大屏手机 |
| md | 640px | 平板 |
| lg | 768px | 小屏笔记本 |
| xl | 1024px | 桌面 |
| 2xl | 1280px | 大屏 |
2. 计算流式排版
公式:clamp(最小值, 首选值, 最大值)
css
/ 视口 320px 到 1200px 之间,字号 16px 到 24px /
font-size: clamp(1rem, 0.5rem + 2vw, 1.5rem);
预计算比例:
css
--fluid-h1: clamp(2rem, 1rem + 3.6vw, 4rem);
--fluid-h2: clamp(1.75rem, 1rem + 2.3vw, 3rem);
--fluid-h3: clamp(1.5rem, 1rem + 1.4vw, 2.25rem);
--fluid-body: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
3. 设置响应式间距
| 令牌 | 移动端 | 平板 | 桌面 |
|------|--------|------|------|
| --space-md | 12px | 16px | 16px |
| --space-lg | 16px | 24px | 32px |
| --space-xl | 24px | 32px | 48px |
| --space-section | 48px | 80px | 120px |
4. 参考: 参见 references/responsive-calculations.md
工作流程 4:开发者交接
场景: 您需要将设计令牌交接给开发团队。
步骤:
1. 以所需格式导出令牌
bash
# 用于 CSS 项目
python scripts/design
token generator.py #0066CC modern css
# 用于 SCSS 项目
python scripts/designtoken generator.py #0066CC modern scss
# 用于 JavaScript/TypeScript
python scripts/designtoken generator.py #0066CC modern json
2. 准备框架集成
React + CSS 变量:
tsx
import ./design-tokens.css;
点击
Tailwind 配置:
javascript
const tokens = require(./design-tokens.json);
module.exports = {
theme: {
colors: tokens.colors,
fontFamily: tokens.typography.fontFamily
}
};
styled-components:
typescript
import tokens from ./design-tokens.json;
const Button = styled.button
background: ${tokens.colors.primary[500]};
padding: ${tokens.spacing[2]} ${tokens.spacing[4]};
;
3. 与 Figma 同步
- 安装 Tokens Studio 插件
- 导入 design-tokens.json
- 令牌自动与 Figma 样式同步
4. 交接清单
- [ ] 令牌文件已添加到项目
- [ ] 构建流水线已配置
- [ ] 主题/CSS 变量已导入
- [ ] 组件库已对齐
- [ ] 文档已生成
5. 参考: 参见 references/developer-handoff.md
工具参考
designtoken generator.py
从品牌色生成完整的设计令牌系统。
参数 值 默认值 描述 brand_color 十六进制颜色 #0066CC 品牌主色 style
modern, classic, playful | modern | 设计风格预设 |
| format | json, css, scss, summary | json | 输出格式 |
示例:
bash
生成 JSON 令牌(默认)
python scripts/design