frontend-design

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Frontend Design Skill — Systematic & Creative Web Development

前端设计技能——系统化与创意化Web开发

Skill Location:
{project_path}/skills/frontend-design/
This skill transforms vague UI style requirements into executable, production-grade frontend code through a systematic design token approach while maintaining creative excellence. It ensures visual consistency, accessibility compliance, and maintainability across all deliverables.

技能存放路径
{project_path}/skills/frontend-design/
本技能通过系统化的设计令牌方法,将模糊的UI样式需求转化为可执行、生产级别的前端代码,同时保持卓越的创意水准。它确保所有交付成果在视觉一致性、无障碍合规性和可维护性上达标。

When to Use This Skill (Trigger Patterns)

何时使用此技能(触发场景)

MUST apply this skill when:
  • User requests any website, web application, or web component development
  • User mentions design styles: "modern", "premium", "minimalist", "dark mode", "SaaS-style"
  • Building dashboards, landing pages, admin panels, or any web UI
  • User asks to "make it look better" or "improve the design"
  • Creating component libraries or design systems
  • User specifies frameworks: React, Vue, Svelte, Next.js, Nuxt, etc.
  • Converting designs/mockups to code
  • User mentions: Tailwind CSS, shadcn/ui, Material-UI, Chakra UI, etc.
Trigger phrases:
  • "build a website/app/component"
  • "create a dashboard/landing page"
  • "design a UI for..."
  • "make it modern/clean/premium"
  • "style this with..."
  • "convert this design to code"
DO NOT use for:
  • Backend API development
  • Pure logic/algorithm implementation
  • Non-visual code tasks

必须使用此技能的场景:
  • 用户要求开发任何网站、Web应用或Web组件
  • 用户提及设计风格:「现代风」「高端风」「极简风」「深色模式」「SaaS风格」
  • 构建仪表盘、着陆页、管理面板或任何Web UI
  • 用户要求「优化外观」或「改进设计」
  • 创建组件库或设计系统
  • 用户指定框架:React、Vue、Svelte、Next.js、Nuxt等
  • 将设计稿/线框图转换为代码
  • 用户提及:Tailwind CSS、shadcn/ui、Material-UI、Chakra UI等
触发短语:
  • 「搭建网站/应用/组件」
  • 「创建仪表盘/着陆页」
  • 「为...设计UI」
  • 「做成现代/简洁/高端风格」
  • 「用...来样式化」
  • 「把这个设计转成代码」
禁止使用的场景:
  • 后端API开发
  • 纯逻辑/算法实现
  • 非可视化代码任务

Skill Architecture

技能架构

This skill provides:
  1. SKILL.md (this file): Core methodology and guidelines
  2. examples/css/: Production-ready CSS examples
    • tokens.css
      - Design token system
    • components.css
      - Reusable component styles
    • utilities.css
      - Utility classes
  3. examples/typescript/: TypeScript implementation examples
    • design-tokens.ts
      - Type-safe token definitions
    • theme-provider.tsx
      - Theme management
    • sample-components.tsx
      - Component examples
  4. templates/: Quick-start templates
    • tailwind-config.js
      - Tailwind configuration
    • globals.css
      - Global styles template

本技能包含:
  1. SKILL.md(本文档):核心方法论与指南
  2. examples/css/:可投入生产的CSS示例
    • tokens.css
      - 设计令牌系统
    • components.css
      - 可复用组件样式
    • utilities.css
      - 工具类
  3. examples/typescript/:TypeScript实现示例
    • design-tokens.ts
      - 类型安全的令牌定义
    • theme-provider.tsx
      - 主题管理
    • sample-components.tsx
      - 组件示例
  4. templates/:快速启动模板
    • tailwind-config.js
      - Tailwind配置
    • globals.css
      - 全局样式模板

Core Principles (Non-Negotiable)

核心原则(不可妥协)

1. Dual-Mode Thinking: System + Creativity

1. 双模式思维:系统化 + 创意化

Systematic Foundation:
  • Design tokens first, UI components second
  • No arbitrary hardcoded values (colors, spacing, shadows, radius)
  • Consistent scales for typography, spacing, radius, elevation
  • Complete state coverage (default/hover/active/focus/disabled + loading/empty/error)
  • Accessibility as a constraint, not an afterthought
Creative Execution:
  • AVOID generic "AI slop" aesthetics (Inter/Roboto fonts, purple gradients, cookie-cutter layouts)
  • Choose BOLD aesthetic direction: brutalist, retro-futuristic, luxury, playful, editorial, etc.
  • Make unexpected choices in typography, color, layout, and motion
  • Each design should feel unique and intentionally crafted for its context
系统化基础:
  • 先定义设计令牌,再开发UI组件
  • 禁止任意硬编码值(颜色、间距、阴影、圆角)
  • 排版、间距、圆角、层级使用统一的刻度体系
  • 覆盖完整状态(默认/悬停/激活/聚焦/禁用 + 加载/空态/错误)
  • 将无障碍设计作为约束,而非事后补充
创意化实现:
  • 避免通用的「AI模板化」美学(Inter/Roboto字体、紫色渐变、千篇一律的布局)
  • 选择鲜明的美学方向:粗犷风、复古未来风、奢华风、趣味风、编辑风等
  • 在排版、颜色、布局和动效上做出意想不到的选择
  • 每个设计都应贴合场景,具备独特性与设计感

2. Tokens-First Methodology

2. 令牌优先方法论

Design Tokens → Component Styles → Page Layouts → Interactive States
Never skip token definition. All visual properties must derive from the token system.
设计令牌 → 组件样式 → 页面布局 → 交互状态
绝不能跳过令牌定义。所有视觉属性必须源自令牌系统。

3. Tech Stack Flexibility

3. 技术栈灵活性

Default stack (if unspecified):
  • Framework: React + TypeScript
  • Styling: Tailwind CSS
  • Components: shadcn/ui
  • Theme: CSS custom properties (light/dark modes)
Supported alternatives:
  • Frameworks: Vue, Svelte, Angular, vanilla HTML/CSS
  • Styling: CSS Modules, SCSS, Styled Components, Emotion
  • Libraries: MUI, Ant Design, Chakra UI, Headless UI
默认技术栈(未指定时):
  • 框架:React + TypeScript
  • 样式方案:Tailwind CSS
  • 组件库:shadcn/ui
  • 主题:CSS自定义属性(亮色/深色模式)
支持的替代方案:
  • 框架:Vue、Svelte、Angular、原生HTML/CSS
  • 样式方案:CSS Modules、SCSS、Styled Components、Emotion
  • 组件库:MUI、Ant Design、Chakra UI、Headless UI

4. Tailwind CSS Best Practices

4. Tailwind CSS最佳实践

⚠️ CRITICAL: Never use Tailwind via CDN
MUST use build-time integration:
bash
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Why build-time is mandatory:
  • ✅ Enables tree-shaking (2-15KB vs 400KB+ bundle)
  • ✅ Full design token customization
  • ✅ IDE autocomplete and type safety
  • ✅ Integrates with bundlers (Vite, webpack, Next.js)
CDN only acceptable for:
  • Quick prototypes/demos
  • Internal testing

⚠️ 关键要求:绝不通过CDN使用Tailwind
必须使用构建时集成:
bash
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
构建时集成的必要性:
  • ✅ 支持摇树优化(包体积2-15KB vs CDN的400KB+)
  • ✅ 完整的设计令牌自定义能力
  • ✅ IDE自动补全与类型安全
  • ✅ 与打包工具集成(Vite、webpack、Next.js)
仅在以下场景可接受CDN:
  • 快速原型/演示
  • 内部测试

Implementation Workflow

实现流程

Phase 1: Design Analysis & Token Definition

阶段1:设计分析与令牌定义

Step 1: Understand Context
- Purpose: What problem does this solve? Who uses it?
- Aesthetic Direction: Choose ONE bold direction
- Technical Constraints: Framework, performance, accessibility needs
- Differentiation: What makes this memorable?
Step 2: Generate Design Tokens
Create comprehensive token system (see
examples/css/tokens.css
and
examples/typescript/design-tokens.ts
):
  1. Semantic Color Slots (light + dark modes):
    --background, --surface, --surface-subtle
    --text, --text-secondary, --text-muted
    --border, --border-subtle
    --primary, --primary-hover, --primary-active, --primary-foreground
    --secondary, --secondary-hover, --secondary-foreground
    --accent, --success, --warning, --danger
  2. Typography Scale:
    Display: 3.5rem/4rem (56px/64px), weight 700-800
    H1: 2.5rem/3rem (40px/48px), weight 700
    H2: 2rem/2.5rem (32px/40px), weight 600
    H3: 1.5rem/2rem (24px/32px), weight 600
    Body: 1rem/1.5rem (16px/24px), weight 400
    Small: 0.875rem/1.25rem (14px/20px), weight 400
    Caption: 0.75rem/1rem (12px/16px), weight 400
  3. Spacing Scale (8px system):
    0.5 → 4px, 1 → 8px, 2 → 16px, 3 → 24px, 4 → 32px
    5 → 40px, 6 → 48px, 8 → 64px, 12 → 96px, 16 → 128px
  4. Radius Scale:
    xs: 2px (badges, tags)
    sm: 4px (buttons, inputs)
    md: 6px (cards, modals)
    lg: 8px (large cards, panels)
    xl: 12px (hero sections)
    2xl: 16px (special elements)
    full: 9999px (pills, avatars)
  5. Shadow Scale:
    sm: Subtle lift (buttons, inputs)
    md: Card elevation
    lg: Modals, dropdowns
    xl: Large modals, drawers
  6. Motion Tokens:
    Duration: 150ms (micro), 220ms (default), 300ms (complex)
    Easing: ease-out (enter), ease-in (exit), ease-in-out (transition)
步骤1:理解场景
- 用途:解决什么问题?用户是谁?
- 美学方向:选择一个鲜明的风格
- 技术约束:框架、性能、无障碍需求
- 差异化:什么让这个设计与众不同?
步骤2:生成设计令牌
创建完整的令牌系统(参考
examples/css/tokens.css
examples/typescript/design-tokens.ts
):
  1. 语义化颜色插槽(亮色+深色模式):
    --background, --surface, --surface-subtle
    --text, --text-secondary, --text-muted
    --border, --border-subtle
    --primary, --primary-hover, --primary-active, --primary-foreground
    --secondary, --secondary-hover, --secondary-foreground
    --accent, --success, --warning, --danger
  2. 排版刻度
    Display: 3.5rem/4rem (56px/64px), 字重700-800
    H1: 2.5rem/3rem (40px/48px), 字重700
    H2: 2rem/2.5rem (32px/40px), 字重600
    H3: 1.5rem/2rem (24px/32px), 字重600
    Body: 1rem/1.5rem (16px/24px), 字重400
    Small: 0.875rem/1.25rem (14px/20px), 字重400
    Caption: 0.75rem/1rem (12px/16px), 字重400
  3. 间距刻度(8px基准):
    0.5 → 4px, 1 → 8px, 2 → 16px, 3 → 24px, 4 → 32px
    5 → 40px, 6 → 48px, 8 → 64px, 12 → 96px, 16 → 128px
  4. 圆角刻度
    xs: 2px(徽章、标签)
    sm: 4px(按钮、输入框)
    md: 6px(卡片、模态框)
    lg: 8px(大卡片、面板)
    xl: 12px( hero区域)
    2xl: 16px(特殊元素)
    full: 9999px(胶囊、头像)
  5. 阴影刻度
    sm: 轻微悬浮(按钮、输入框)
    md: 卡片层级
    lg: 模态框、下拉菜单
    xl: 大型模态框、侧边栏
  6. 动效令牌
    时长:150ms(微交互)、220ms(默认)、300ms(复杂交互)
    缓动函数:ease-out(进入)、ease-in(退出)、ease-in-out(过渡)

Phase 2: Component Development

阶段2:组件开发

Step 3: Build Reusable Components
Follow this structure (see
examples/typescript/sample-components.tsx
):
typescript
interface ComponentProps {
  variant?: 'primary' | 'secondary' | 'outline' | 'ghost';
  size?: 'sm' | 'md' | 'lg';
  state?: 'default' | 'hover' | 'active' | 'disabled' | 'loading';
}
Required component states:
  • Default, Hover, Active, Focus, Disabled
  • Loading (skeleton/spinner)
  • Empty state (clear messaging)
  • Error state (recovery instructions)
Required component features:
  • Accessible (ARIA labels, keyboard navigation)
  • Responsive (mobile-first)
  • Theme-aware (light/dark mode)
  • Token-based styling (no hardcoded values)
步骤3:构建可复用组件
遵循以下结构(参考
examples/typescript/sample-components.tsx
):
typescript
interface ComponentProps {
  variant?: 'primary' | 'secondary' | 'outline' | 'ghost';
  size?: 'sm' | 'md' | 'lg';
  state?: 'default' | 'hover' | 'active' | 'disabled' | 'loading';
}
必填组件状态:
  • 默认、悬停、激活、聚焦、禁用
  • 加载(骨架屏/加载动画)
  • 空态(清晰提示)
  • 错误态(恢复指引)
必填组件特性:
  • 无障碍支持(ARIA标签、键盘导航)
  • 响应式(移动端优先)
  • 主题适配(亮色/深色模式)
  • 令牌驱动样式(无硬编码值)

Phase 3: Page Assembly

阶段3:页面组装

Step 4: Compose Pages from Components
- Use established tokens and components only
- Mobile-first responsive design
- Loading states for async content
- Empty states with clear CTAs
- Error states with recovery options
步骤4:用组件组合页面
- 仅使用已定义的令牌和组件
- 移动端优先的响应式设计
- 异步内容的加载状态
- 带清晰CTA的空态
- 带恢复选项的错误态

Phase 4: Quality Assurance

阶段4:质量保证

Step 5: Self-Review Checklist
  • All colors from semantic tokens (no random hex/rgb)
  • All spacing from spacing scale
  • All radius from radius scale
  • Shadows justified by hierarchy
  • Clear type hierarchy with comfortable line-height (1.5+)
  • All interactive states implemented and tested
  • Accessibility: WCAG AA contrast, keyboard navigation, ARIA, focus indicators
  • Responsive: works on mobile (375px), tablet (768px), desktop (1024px+)
  • Loading/empty/error states included
  • Code is maintainable: DRY, clear naming, documented

步骤5:自我检查清单
  • 所有颜色来自语义化令牌(无随机hex/rgb值)
  • 所有间距来自间距刻度
  • 所有圆角来自圆角刻度
  • 阴影使用符合层级逻辑
  • 清晰的排版层级,行高舒适(≥1.5)
  • 所有交互状态已实现并测试
  • 无障碍:WCAG AA对比度、键盘导航、ARIA、聚焦指示器
  • 响应式:在移动端(375px)、平板(768px)、桌面端(1024px+)均正常工作
  • 包含加载/空态/错误态
  • 代码可维护:DRY、命名清晰、有文档

Design Direction Templates

设计方向模板

1. Minimal Premium SaaS (Most Universal)

1. 极简高端SaaS风格(最通用)

Visual Style: Minimal Premium SaaS
- Generous whitespace (1.5-2x standard padding)
- Near-white background with subtle surface contrast
- Light borders (1px, low-opacity)
- Very subtle elevation (avoid heavy shadows)
- Unified control height: 44-48px
- Medium-large radius: 6-8px
- Gentle hover states (background shift only)
- Clear but not harsh focus rings
- Low-contrast dividers
- Priority: Readability and consistency
Best for: Enterprise apps, B2B SaaS, productivity tools
视觉风格:极简高端SaaS
- 充足留白(1.5-2倍标准内边距)
- 近白色背景搭配细微的表面对比度
- 细边框(1px,低透明度)
- 非常轻微的层级阴影(避免厚重阴影)
- 统一的控件高度:44-48px
- 中等偏大圆角:6-8px
- 柔和的悬停状态(仅背景变化)
- 清晰但不刺眼的聚焦环
- 低对比度分隔线
- 优先级:可读性与一致性
最佳适用场景: 企业应用、B2B SaaS、生产力工具

2. Bold Editorial

2. 大胆编辑风格

Visual Style: Bold Editorial
- Strong typographic hierarchy (large display fonts)
- High contrast (black/white or dark/light extremes)
- Generous use of negative space
- Asymmetric layouts with intentional imbalance
- Grid-breaking elements
- Minimal color palette (1-2 accent colors max)
- Sharp, geometric shapes
- Dramatic scale differences
- Priority: Visual impact and memorability
Best for: Marketing sites, portfolios, content-heavy sites
视觉风格:大胆编辑
- 强烈的排版层级(大尺寸标题字体)
- 高对比度(黑/白或明暗极端对比)
- 大量留白
- 不对称布局,刻意营造不平衡感
- 打破网格的元素
- 极简配色(最多1-2个强调色)
- 锐利的几何形状
- 强烈的尺寸差异
- 优先级:视觉冲击力与记忆点
最佳适用场景: 营销网站、作品集、内容型网站

3. Soft & Organic

3. 柔和有机风格

Visual Style: Soft & Organic
- Rounded corners everywhere (12-24px radius)
- Soft shadows and subtle gradients
- Pastel or muted color palette
- Gentle animations (ease-in-out, 300-400ms)
- Curved elements and flowing layouts
- Generous padding (1.5-2x standard)
- Soft, blurred backgrounds
- Priority: Approachability and comfort
Best for: Consumer apps, wellness, lifestyle brands
视觉风格:柔和有机
- 全圆角(12-24px圆角)
- 柔和阴影与细微渐变
- 马卡龙色或低饱和度配色
- 平缓动画(ease-in-out,300-400ms)
- 弧形元素与流畅布局
- 充足内边距(1.5-2倍标准)
- 柔和模糊背景
- 优先级:亲和力与舒适感
最佳适用场景: 消费级应用、健康养生、生活方式品牌

4. Dark Neon (Restrained)

4. 克制的深色霓虹风格

Visual Style: Dark Neon
- Dark background (#0a0a0a to #1a1a1a, NOT pure black)
- High contrast text (#ffffff or #fafafa)
- Accent colors ONLY for CTAs and key states
- Subtle glow on hover (box-shadow with accent color)
- Minimal borders (use subtle outlines)
- Optional: Subtle noise texture
- Restrained use of neon (less is more)
- Priority: Focus and sophisticated edge
Best for: Developer tools, gaming, tech products
视觉风格:克制的深色霓虹
- 深色背景(#0a0a0a至#1a1a1a,不要纯黑)
- 高对比度文字(#ffffff或#fafafa)
- 强调色仅用于CTA和关键状态
- 悬停时的轻微发光(带强调色的box-shadow)
- 极简边框(用细微轮廓代替)
- 可选:细微噪点纹理
- 克制使用霓虹效果(少即是多)
- 优先级:聚焦感与精致的科技感
最佳适用场景: 开发者工具、游戏、科技产品

5. Playful & Colorful

5. 趣味多彩风格

Visual Style: Playful & Colorful
- Vibrant color palette (3-5 colors)
- Rounded corners (8-16px)
- Micro-animations on hover/interaction
- Generous padding and breathing room
- Friendly, geometric illustrations
- Smooth transitions (200-250ms)
- High energy but balanced
- Priority: Delight and engagement
Best for: Consumer apps, children's products, creative tools

视觉风格:趣味多彩
- 鲜艳配色(3-5种颜色)
- 圆角(8-16px)
- 悬停/交互时的微动画
- 充足内边距与呼吸空间
- 友好的几何插画
- 平滑过渡(200-250ms)
- 高活力但平衡
- 优先级:愉悦感与参与度
最佳适用场景: 消费级应用、儿童产品、创意工具

Standard Prompting Workflow

标准提示词工作流

Master Prompt Template

主提示词模板

You are a Design Systems Engineer + Senior Frontend UI Developer with expertise in creative design execution.

[TECH STACK]
- Framework: {{FRAMEWORK = React + TypeScript}}
- Styling: {{STYLING = Tailwind CSS}}
- Components: {{UI_LIB = shadcn/ui}}
- Theme: CSS variables (light/dark modes)

[DESIGN SYSTEM RULES - MANDATORY]
1. Layout: 8px spacing system; mobile-first responsive
2. Typography: Clear hierarchy (Display/H1/H2/H3/Body/Small/Caption); line-height 1.5+
3. Colors: Semantic tokens ONLY (no hardcoded values)
4. Shape: Tiered radius system; tap targets ≥ 44px
5. Elevation: Minimal shadows; borders for hierarchy
6. Motion: Subtle transitions (150-220ms); restrained animations
7. Accessibility: WCAG AA; keyboard navigation; ARIA; focus indicators

[AESTHETIC DIRECTION]
Style: {{STYLE = Minimal Premium SaaS}}
Key Differentiator: {{UNIQUE_FEATURE}}
Target Audience: {{AUDIENCE}}

[INTERACTION STATES - REQUIRED]
✓ Default, Hover, Active, Focus, Disabled
✓ Loading (skeleton), Empty (with messaging), Error (with recovery)

[OUTPUT REQUIREMENTS]
1. Design Tokens (CSS variables + TypeScript types)
2. Component implementations (copy-paste ready)
3. Page layouts with all states
4. NO hardcoded values; reference tokens only
5. Minimal but clear code comments
你是一名设计系统工程师 + 资深前端UI开发者,擅长创意设计实现。

[技术栈]
- 框架:{{FRAMEWORK = React + TypeScript}}
- 样式方案:{{STYLING = Tailwind CSS}}
- 组件库:{{UI_LIB = shadcn/ui}}
- 主题:CSS变量(亮色/深色模式)

[设计系统规则 - 强制遵守]
1. 布局:8px间距系统;移动端优先响应式
2. 排版:清晰层级(Display/H1/H2/H3/Body/Small/Caption);行高≥1.5
3. 颜色:仅使用语义化令牌(无硬编码值)
4. 形状:分层圆角系统;点击目标≥44px
5. 层级:极简阴影;用边框区分层级
6. 动效:细微过渡(150-220ms);克制动画
7. 无障碍:WCAG AA标准;键盘导航;ARIA;聚焦指示器

[美学方向]
风格:{{STYLE = 极简高端SaaS}}
差异化特性:{{UNIQUE_FEATURE}}
目标受众:{{AUDIENCE}}

[交互状态 - 必填]
✓ 默认、悬停、激活、聚焦、禁用
✓ 加载(骨架屏)、空态(带提示)、错误态(带恢复选项)

[输出要求]
1. 设计令牌(CSS变量 + TypeScript类型)
2. 组件实现(可直接复制粘贴)
3. 包含所有状态的页面布局
4. 无硬编码值;仅引用令牌
5. 简洁清晰的代码注释

Token Generation Prompt

令牌生成提示词

Generate a complete Design Token system including:

1. Semantic color slots (CSS custom properties):
   - Light mode + Dark mode variants
   - Background, surface, text, border, primary, secondary, accent, semantic colors
   - Interactive states for each (hover, active)

2. Typography scale:
   - Display, H1-H6, Body, Small, Caption, Monospace
   - Include: font-size, line-height, font-weight, letter-spacing

3. Spacing scale (8px base):
   - 0.5, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24 (in rem)

4. Radius scale:
   - xs (2px), sm (4px), md (6px), lg (8px), xl (12px), 2xl (16px), full

5. Shadow scale:
   - sm, md, lg, xl (with color and blur values)
   - Usage guidelines for each tier

6. Motion tokens:
   - Duration: fast (150ms), base (220ms), slow (300ms)
   - Easing: ease-out, ease-in, ease-in-out

7. Component density:
   - Button heights: sm (36px), md (44px), lg (48px)
   - Input heights: sm (36px), md (40px)
   - Padding scales

Output format:
- CSS custom properties (globals.css)
- Tailwind config integration
- TypeScript type definitions
- Usage examples for each token category

DO NOT write component code yet.
生成完整的设计令牌系统,包含:

1. 语义化颜色插槽(CSS自定义属性):
   - 亮色模式 + 深色模式变体
   - 背景、表面、文字、边框、主色、次色、强调色、语义化颜色
   - 每种颜色的交互状态(悬停、激活)

2. 排版刻度:
   - Display、H1-H6、Body、Small、Caption、Monospace
   - 包含:字体大小、行高、字重、字间距

3. 间距刻度(8px基准):
   - 0.5, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24(单位rem)

4. 圆角刻度:
   - xs (2px), sm (4px), md (6px), lg (8px), xl (12px), 2xl (16px), full

5. 阴影刻度:
   - sm, md, lg, xl(包含颜色与模糊值)
   - 每个层级的使用指南

6. 动效令牌:
   - 时长:快速(150ms)、基准(220ms)、慢速(300ms)
   - 缓动函数:ease-out, ease-in, ease-in-out

7. 组件密度:
   - 按钮高度:sm (36px), md (44px), lg (48px)
   - 输入框高度:sm (36px), md (40px)
   - 内边距刻度

输出格式:
- CSS自定义属性(globals.css)
- Tailwind配置集成
- TypeScript类型定义
- 每个令牌类别的使用示例

暂不编写组件代码。

Component Implementation Prompt

组件实现提示词

Using the established Design Tokens, implement: <{{COMPONENT_NAME}} />

Requirements:
- Props: variant, size, state, className (for composition)
- States: default, hover, focus, active, disabled, loading, error
- Accessibility: keyboard navigation, ARIA labels, focus management
- Responsive: mobile-first, touch-friendly (44px+ tap targets)
- Styling: Use tokens ONLY (no hardcoded values)
- TypeScript: Full type safety with exported interfaces

Include:
1. Component implementation
2. Usage examples (3-5 variants)
3. Loading state example
4. Error state example
5. Accessibility notes

Output: Production-ready, copy-paste code with JSDoc comments.
使用已定义的设计令牌,实现:<{{COMPONENT_NAME}} />

要求:
- Props:variant、size、state、className(用于组合)
- 状态:默认、悬停、聚焦、激活、禁用、加载、错误
- 无障碍:键盘导航、ARIA标签、聚焦管理
- 响应式:移动端优先、触控友好(点击目标≥44px)
- 样式:仅使用令牌(无硬编码值)
- TypeScript:完整的类型安全,导出接口

包含:
1. 组件实现
2. 使用示例(3-5种变体)
3. 加载状态示例
4. 错误状态示例
5. 无障碍说明

输出:可直接投入生产、复制粘贴即用的代码,带JSDoc注释。

Page Development Prompt

页面开发提示词

Build page: {{PAGE_NAME}}

Using:
- Established Design Tokens
- Implemented Components
- {{STYLE}} aesthetic direction

Requirements:
- Responsive layout (mobile/tablet/desktop)
- All interaction states (hover/focus/active/disabled)
- Loading skeleton for async content
- Empty state with clear CTA
- Error state with recovery options
- Accessible (keyboard nav, ARIA, WCAG AA)
- No hardcoded styles (components + utility classes only)

Include:
1. Page component with mock data
2. Loading state variant
3. Empty state variant
4. Error state variant
5. Responsive behavior notes

Output: Complete, runnable page component.
构建页面:{{PAGE_NAME}}

使用:
- 已定义的设计令牌
- 已实现的组件
- {{STYLE}}美学方向

要求:
- 响应式布局(移动端/平板/桌面端)
- 所有交互状态(悬停/聚焦/激活/禁用)
- 异步内容的加载骨架屏
- 带清晰CTA的空态
- 带恢复选项的错误态
- 无障碍(键盘导航、ARIA、WCAG AA)
- 无硬编码样式(仅使用组件+工具类)

包含:
1. 带模拟数据的页面组件
2. 加载状态变体
3. 空态变体
4. 错误态变体
5. 响应式行为说明

输出:完整、可运行的页面组件。

Review & Optimization Prompt

评审与优化提示词

You are a Frontend Code Reviewer specializing in design systems and accessibility.

Review the implementation and check:

1. Token Compliance:
   - Any hardcoded colors, sizes, shadows, radius?
   - All values from established scales?

2. Typography:
   - Clear hierarchy?
   - Comfortable line-height (1.5+)?
   - Appropriate font sizes for each level?

3. Spacing & Layout:
   - Consistent use of spacing scale?
   - Adequate whitespace?
   - No awkward gaps or cramped sections?

4. Interactive States:
   - Hover/focus/active clearly distinct?
   - Disabled state obviously different?
   - Loading/empty/error states implemented?

5. Accessibility:
   - WCAG AA contrast met?
   - Keyboard reachable?
   - ARIA labels complete?
   - Focus indicators visible?
   - Semantic HTML?

6. Responsive Design:
   - Mobile layout functional (375px)?
   - Tablet optimized (768px)?
   - Desktop enhanced (1024px+)?
   - Touch targets ≥ 44px?

7. Maintainability:
   - DRY principles followed?
   - Clear component boundaries?
   - Consistent naming?
   - Adequate comments?

8. Creative Execution:
   - Matches intended aesthetic?
   - Avoids generic patterns?
   - Unique and memorable?

Output:
- Findings (sorted by severity: Critical, High, Medium, Low)
- Specific fixes (code patches)
- Improvement suggestions

你是一名专注于设计系统与无障碍的前端代码评审员。

评审以下实现并检查:

1. 令牌合规性:
   - 是否存在硬编码的颜色、尺寸、阴影、圆角?
   - 所有值是否来自已定义的刻度?

2. 排版:
   - 层级是否清晰?
   - 行高是否舒适(≥1.5)?
   - 每个层级的字体大小是否合适?

3. 间距与布局:
   - 是否一致使用间距刻度?
   - 留白是否充足?
   - 是否存在尴尬的间隙或拥挤的区域?

4. 交互状态:
   - 悬停/聚焦/激活状态是否清晰可辨?
   - 禁用状态是否明显不同?
   - 是否实现了加载/空态/错误态?

5. 无障碍:
   - 是否符合WCAG AA对比度要求?
   - 是否可通过键盘访问?
   - ARIA标签是否完整?
   - 聚焦指示器是否可见?
   - 是否使用语义化HTML?

6. 响应式设计:
   - 移动端布局(375px)是否可用?
   - 平板布局(768px)是否优化?
   - 桌面端布局(1024px+)是否增强?
   - 点击目标是否≥44px?

7. 可维护性:
   - 是否遵循DRY原则?
   - 组件边界是否清晰?
   - 命名是否一致?
   - 注释是否充足?

8. 创意实现:
   - 是否匹配预期美学方向?
   - 是否避免了通用模式?
   - 是否独特且令人难忘?

输出:
- 问题发现(按严重程度排序:Critical、High、Medium、Low)
- 具体修复方案(代码补丁)
- 改进建议

Common Pitfalls & Solutions

常见陷阱与解决方案

❌ Problem: Vague aesthetic descriptions

❌ 问题:模糊的美学描述

✅ Solution: Force actionable specifications

✅ 解决方案:强制可落地的规格

DON'T: "Make it modern and clean"
DO: 
- Whitespace: 1.5x standard padding (24px instead of 16px)
- Typography: Display 56px, H1 40px, Body 16px, line-height 1.6
- Colors: Neutral gray scale (50-900) + single accent color
- Shadows: Maximum 2 shadow tokens (card + modal only)
- Radius: Consistent 6px (buttons/inputs) and 8px (cards)
- Borders: 1px with --border-subtle (#e5e7eb in light mode)
- Transitions: 150ms ease-out only
不要:「做成现代简洁风格」
要:
- 留白:1.5倍标准内边距(24px代替16px)
- 排版:Display 56px、H1 40px、Body 16px,行高1.6
- 颜色:中性灰度(50-900)+ 单一强调色
- 阴影:最多使用2种阴影令牌(仅卡片+模态框)
- 圆角:按钮/输入框统一6px,卡片8px
- 边框:1px --border-subtle(亮色模式下为#e5e7eb)
- 过渡:仅使用150ms ease-out

❌ Problem: Each component invents its own styles

❌ 问题:每个组件自行定义样式

✅ Solution: Enforce token-only rule

✅ 解决方案:强制仅使用令牌

RULE: Every visual property must map to a token.

Violations:
- ❌ bg-gray-100 (hardcoded Tailwind color)
- ❌ p-[17px] (arbitrary padding not in scale)
- ❌ rounded-[5px] (radius not in scale)
- ❌ shadow-[0_2px_8px_rgba(0,0,0,0.1)] (arbitrary shadow)

Correct:
- ✅ bg-surface (semantic token)
- ✅ p-4 (maps to spacing scale: 16px)
- ✅ rounded-md (maps to radius scale: 6px)
- ✅ shadow-sm (maps to shadow token)
规则:每个视觉属性必须映射到一个令牌。

违规示例:
- ❌ bg-gray-100(硬编码Tailwind颜色)
- ❌ p-[17px](不在刻度内的任意内边距)
- ❌ rounded-[5px](不在刻度内的圆角)
- ❌ shadow-[0_2px_8px_rgba(0,0,0,0.1)](任意阴影)

正确示例:
- ✅ bg-surface(语义化令牌)
- ✅ p-4(对应间距刻度:16px)
- ✅ rounded-md(对应圆角刻度:6px)
- ✅ shadow-sm(对应阴影令牌)

❌ Problem: Missing interactive states

❌ 问题:缺失交互状态

✅ Solution: State coverage checklist

✅ 解决方案:状态覆盖检查清单

For EVERY interactive element, implement:

Visual States:
- [ ] Default (base appearance)
- [ ] Hover (background shift, shadow, scale)
- [ ] Active (pressed state, slightly darker)
- [ ] Focus (visible ring, keyboard accessible)
- [ ] Disabled (reduced opacity, cursor not-allowed)

Data States:
- [ ] Loading (skeleton or spinner with same dimensions)
- [ ] Empty (clear message + CTA)
- [ ] Error (error message + retry option)

Test each state in isolation and in combination.
每个交互元素必须实现:

视觉状态:
- [ ] 默认(基础外观)
- [ ] 悬停(背景变化、阴影、缩放)
- [ ] 激活(按压状态,颜色稍深)
- [ ] 聚焦(可见的环,键盘可访问)
- [ ] 禁用(透明度降低,光标为not-allowed)

数据状态:
- [ ] 加载(骨架屏或与原尺寸一致的加载动画)
- [ ] 空态(清晰提示+CTA)
- [ ] 错误态(错误提示+重试选项)

单独测试每个状态及状态组合。

❌ Problem: Generic AI aesthetics

❌ 问题:通用AI美学

✅ Solution: Force creative differentiation

✅ 解决方案:强制创意差异化

BANNED PATTERNS (overused in AI-generated UIs):
- ❌ Inter/Roboto/System fonts as primary choice
- ❌ Purple gradients on white backgrounds
- ❌ Card-grid-card-grid layouts only
- ❌ Generic blue (#3b82f6) as primary
- ❌ Default Tailwind color palette with no customization

REQUIRED CREATIVE CHOICES:
- ✅ Select distinctive fonts (Google Fonts, Adobe Fonts, custom)
- ✅ Build custom color palette (not Tailwind defaults)
- ✅ Design unique layouts (asymmetry, overlap, grid-breaking)
- ✅ Add personality: illustrations, icons, textures, patterns
- ✅ Create signature elements (unique buttons, cards, headers)

Ask yourself: "Would someone recognize this as uniquely designed for this purpose?"
禁止使用的模式(AI生成UI中过度使用):
- ❌ 将Inter/Roboto/系统字体作为首选
- ❌ 白色背景搭配紫色渐变
- ❌ 仅使用卡片-网格-卡片-网格布局
- ❌ 通用蓝色(#3b82f6)作为主色
- ❌ 使用默认Tailwind配色而不自定义

必须做出的创意选择:
- ✅ 选择独特字体(Google Fonts、Adobe Fonts、自定义字体)
- ✅ 构建自定义配色(非Tailwind默认)
- ✅ 设计独特布局(不对称、重叠、打破网格)
- ✅ 添加个性元素:插画、图标、纹理、图案
- ✅ 创建标志性元素(独特按钮、卡片、头部)

自问:「别人能认出这是为该场景量身设计的吗?」

❌ Problem: Accessibility as afterthought

❌ 问题:无障碍设计事后补充

✅ Solution: Accessibility as constraint

✅ 解决方案:将无障碍作为约束

Build accessibility IN, not ON:

Color Contrast:
- Run contrast checker on all text/background pairs
- Minimum WCAG AA: 4.5:1 (normal text), 3:1 (large text)
- Use tools: WebAIM Contrast Checker, Chrome DevTools

Keyboard Navigation:
- Tab order follows visual flow
- All interactive elements keyboard reachable
- Focus indicator always visible (outline or ring)
- Escape closes modals/dropdowns

ARIA & Semantics:
- Use semantic HTML first (<button>, <nav>, <main>)
- Add ARIA only when semantic HTML insufficient
- aria-label for icon-only buttons
- aria-describedby for form errors
- aria-expanded for disclosure widgets

Test with:
- Keyboard only (no mouse)
- Screen reader (NVDA, JAWS, VoiceOver)
- Reduced motion preference (prefers-reduced-motion)

从一开始就融入无障碍设计:

颜色对比度:
- 检查所有文字/背景对的对比度
- 最低WCAG AA标准:普通文本4.5:1,大文本3:1
- 使用工具:WebAIM Contrast Checker、Chrome DevTools

键盘导航:
- Tab顺序遵循视觉流
- 所有交互元素可通过键盘访问
- 聚焦指示器始终可见(轮廓或环)
- Escape可关闭模态框/下拉菜单

ARIA与语义化:
- 优先使用语义化HTML(<button>、<nav>、<main>)
- 仅在语义化HTML不足时添加ARIA
- 纯图标按钮添加aria-label
- 表单错误添加aria-describedby
- 展开控件添加aria-expanded

测试工具:
- 仅使用键盘(无鼠标)
- 屏幕阅读器(NVDA、JAWS、VoiceOver)
- 减少动效偏好设置(prefers-reduced-motion)

Quick Start: Complete Example

快速开始:完整示例

You are a Design Systems Engineer + Senior Frontend UI Developer.

[STACK]
React + TypeScript + Tailwind CSS + shadcn/ui

[TASK]
Build a Team Dashboard for a project management app.

[AESTHETIC]
Style: Minimal Premium SaaS
Unique Element: Subtle animated background gradient
Audience: Product managers and software teams

[REQUIREMENTS]
1. Components needed:
   - Header with search and user menu
   - Team members grid (name, role, avatar, status)
   - Invite modal (name, email, role selector)
   - Empty state (no team members yet)
   - Loading skeleton

2. Features:
   - Search/filter team members
   - Click to view member details
   - Invite button opens modal
   - Sort by name/role/status

3. States:
   - Loading (skeleton grid)
   - Empty (with invite CTA)
   - Populated (member cards)
   - Error (failed to load)

[OUTPUT]
1. Design Tokens (globals.css + tailwind.config.ts)
2. Component implementations:
   - TeamMemberCard
   - InviteModal
   - SearchBar
   - UserMenu
3. TeamDashboard page component
4. All states (loading/empty/error)
5. Full TypeScript types
6. Accessibility notes

Rules:
- Mobile-first responsive
- No hardcoded values (use tokens)
- WCAG AA compliance
- Include hover/focus/active states
- Add subtle micro-interactions

你是一名设计系统工程师 + 资深前端UI开发者。

[技术栈]
React + TypeScript + Tailwind CSS + shadcn/ui

[任务]
为项目管理应用构建团队仪表盘。

[美学方向]
风格:极简高端SaaS
独特元素:细微的动态背景渐变
受众:产品经理与软件团队

[要求]
1. 需要的组件:
   - 带搜索与用户菜单的头部
   - 团队成员网格(姓名、角色、头像、状态)
   - 邀请模态框(姓名、邮箱、角色选择器)
   - 空态(暂无团队成员)
   - 加载骨架屏

2. 功能:
   - 搜索/筛选团队成员
   - 点击查看成员详情
   - 邀请按钮打开模态框
   - 按姓名/角色/状态排序

3. 状态:
   - 加载(骨架屏网格)
   - 空态(带邀请CTA)
   - 已填充(成员卡片)
   - 错误(加载失败)

[输出]
1. 设计令牌(globals.css + tailwind.config.ts)
2. 组件实现:
   - TeamMemberCard
   - InviteModal
   - SearchBar
   - UserMenu
3. TeamDashboard页面组件
4. 所有状态(加载/空态/错误)
5. 完整TypeScript类型
6. 无障碍说明

规则:
- 移动端优先响应式
- 无硬编码值(使用令牌)
- WCAG AA合规
- 包含悬停/聚焦/激活状态
- 添加细微微交互

Examples & Templates

示例与模板

This skill includes production-ready examples in
examples/
:
本技能在
examples/
目录下包含可投入生产的示例:

CSS Examples (
examples/css/
)

CSS示例(
examples/css/

tokens.css
— Complete design token system
  • Semantic color tokens (light + dark modes)
  • Typography scale with fluid sizing
  • Spacing, radius, shadow, motion scales
  • CSS custom properties ready to use
components.css
— Component style library
  • Buttons (variants, sizes, states)
  • Inputs, textareas, selects
  • Cards, modals, tooltips
  • Navigation, headers, footers
  • Loading skeletons
  • All with state variants (hover/focus/active/disabled)
utilities.css
— Utility class library
  • Layout utilities (flex, grid, container)
  • Spacing utilities (margin, padding)
  • Typography utilities (sizes, weights, line-heights)
  • State utilities (hover, focus, group variants)
tokens.css
— 完整设计令牌系统
  • 语义化颜色令牌(亮色+深色模式)
  • 带流体尺寸的排版刻度
  • 间距、圆角、阴影、动效刻度
  • 可直接使用的CSS自定义属性
components.css
— 组件样式库
  • 按钮(变体、尺寸、状态)
  • 输入框、文本域、选择器
  • 卡片、模态框、提示框
  • 导航、头部、底部
  • 加载骨架屏
  • 所有状态变体(悬停/聚焦/激活/禁用)
utilities.css
— 工具类库
  • 布局工具类(flex、grid、容器)
  • 间距工具类(外边距、内边距)
  • 排版工具类(尺寸、字重、行高)
  • 状态工具类(悬停、聚焦、组变体)

TypeScript Examples (
examples/typescript/
)

TypeScript示例(
examples/typescript/

design-tokens.ts
— Type-safe token definitions
  • Token interfaces and types
  • Design system configuration
  • Theme type definitions
  • Token validators
theme-provider.tsx
— Theme management system
  • Theme context provider
  • Dark mode toggle
  • System preference detection
  • Theme persistence (localStorage)
sample-components.tsx
— Production component examples
  • Button component (all variants)
  • Input component (with validation)
  • Card component (with loading states)
  • Modal component (with focus management)
  • All with full TypeScript types and accessibility
design-tokens.ts
— 类型安全的令牌定义
  • 令牌接口与类型
  • 设计系统配置
  • 主题类型定义
  • 令牌验证器
theme-provider.tsx
— 主题管理系统
  • 主题上下文提供者
  • 深色模式切换
  • 系统偏好检测
  • 主题持久化(localStorage)
sample-components.tsx
— 可投入生产的组件示例
  • 按钮组件(所有变体)
  • 输入组件(带验证)
  • 卡片组件(带加载状态)
  • 模态框组件(带聚焦管理)
  • 所有组件均包含完整TypeScript类型与无障碍支持

Templates (
templates/
)

模板(
templates/

tailwind-config.js
— Optimized Tailwind configuration
  • Custom color palette
  • Typography plugin setup
  • Spacing and sizing scales
  • Plugin configurations
globals.css
— Global styles template
  • CSS reset/normalize
  • Token definitions
  • Base element styles
  • Utility classes

tailwind-config.js
— 优化后的Tailwind配置
  • 自定义配色
  • 排版插件设置
  • 间距与尺寸刻度
  • 插件配置
globals.css
— 全局样式模板
  • CSS重置/归一化
  • 令牌定义
  • 基础元素样式
  • 工具类

Output Quality Standards

输出质量标准

Every deliverable must meet:
每个交付成果必须满足:

Code Quality

代码质量

  • ✅ Production-ready (copy-paste deployable)
  • ✅ TypeScript with full type safety
  • ✅ ESLint/Prettier compliant
  • ✅ No hardcoded magic numbers
  • ✅ DRY (Don't Repeat Yourself)
  • ✅ Clear, descriptive naming
  • ✅ JSDoc comments for complex logic
  • ✅ 可投入生产(可直接复制部署)
  • ✅ 带完整类型安全的TypeScript
  • ✅ 符合ESLint/Prettier规范
  • ✅ 无硬编码魔法值
  • ✅ 遵循DRY原则
  • ✅ 命名清晰、描述性强
  • ✅ 复杂逻辑带JSDoc注释

Design Quality

设计质量

  • ✅ Unique, memorable aesthetic
  • ✅ Consistent token usage
  • ✅ Cohesive visual language
  • ✅ Thoughtful micro-interactions
  • ✅ Polished details (shadows, transitions, spacing)
  • ✅ 独特、令人难忘的美学
  • ✅ 令牌使用一致
  • ✅ 视觉语言连贯
  • ✅ 贴心的微交互
  • ✅ 细节打磨到位(阴影、过渡、间距)

Accessibility Quality

无障碍质量

  • ✅ WCAG AA minimum (AAA preferred)
  • ✅ Keyboard navigable
  • ✅ Screen reader friendly
  • ✅ Focus management
  • ✅ Semantic HTML
  • ✅ ARIA when necessary
  • ✅ 最低WCAG AA标准(优先AAA)
  • ✅ 可键盘导航
  • ✅ 屏幕阅读器友好
  • ✅ 聚焦管理
  • ✅ 语义化HTML
  • ✅ 必要时使用ARIA

Performance Quality

性能质量

  • ✅ Optimized bundle size (tree-shaking)
  • ✅ Lazy loading for heavy components
  • ✅ CSS-only animations when possible
  • ✅ Minimal re-renders (React memo/useMemo)
  • ✅ Responsive images (srcset, sizes)

  • ✅ 优化包体积(摇树优化)
  • ✅ 重型组件懒加载
  • ✅ 尽可能使用纯CSS动画
  • ✅ 最少重渲染(React memo/useMemo)
  • ✅ 响应式图片(srcset、sizes)

Verification Checklist

验证清单

Before delivering code, verify:
Tokens & System:
  • All colors from semantic tokens (no hex/rgb hardcoded)
  • All spacing from spacing scale (8px system)
  • All radius from radius scale (xs/sm/md/lg/xl/2xl/full)
  • Shadows minimal and justified
  • Typography hierarchy clear (Display/H1/H2/H3/Body/Small/Caption)
  • Line-height comfortable (1.5+ for body text)
States & Interactions:
  • Default state implemented
  • Hover state (visual feedback)
  • Active state (pressed appearance)
  • Focus state (keyboard ring visible)
  • Disabled state (reduced opacity, no pointer)
  • Loading state (skeleton or spinner)
  • Empty state (clear message + CTA)
  • Error state (message + recovery)
Accessibility:
  • WCAG AA contrast (4.5:1 text, 3:1 large text)
  • Keyboard navigation complete
  • Focus indicators always visible
  • Semantic HTML used
  • ARIA labels where needed
  • Form labels associated
  • Alt text on images
Responsive Design:
  • Mobile layout (375px+) functional
  • Tablet layout (768px+) optimized
  • Desktop layout (1024px+) enhanced
  • Touch targets ≥ 44px
  • Text readable on all sizes
  • No horizontal scroll
Creative Execution:
  • Unique aesthetic (not generic)
  • Matches stated design direction
  • Memorable visual element
  • Cohesive design language
  • Polished details
Code Quality:
  • TypeScript types complete
  • No linter errors
  • DRY principles followed
  • Clear component boundaries
  • Consistent naming conventions
  • Adequate comments
  • Production-ready (can deploy as-is)

交付代码前,验证:
令牌与系统:
  • 所有颜色来自语义化令牌(无硬编码hex/rgb)
  • 所有间距来自间距刻度(8px系统)
  • 所有圆角来自圆角刻度(xs/sm/md/lg/xl/2xl/full)
  • 阴影使用符合层级逻辑
  • 排版层级清晰(Display/H1/H2/H3/Body/Small/Caption)
  • 正文行高舒适(≥1.5)
状态与交互:
  • 实现默认状态
  • 实现悬停状态(视觉反馈)
  • 实现激活状态(按压外观)
  • 实现聚焦状态(可见的键盘环)
  • 实现禁用状态(透明度降低,无指针)
  • 实现加载状态(骨架屏或加载动画)
  • 实现空态(清晰提示+CTA)
  • 实现错误态(提示+恢复选项)
无障碍:
  • 符合WCAG AA对比度(普通文本4.5:1,大文本3:1)
  • 完整键盘导航
  • 聚焦指示器始终可见
  • 使用语义化HTML
  • 必要时添加ARIA标签
  • 表单标签关联正确
  • 图片带alt文本
响应式设计:
  • 移动端布局(375px+)可用
  • 平板布局(768px+)已优化
  • 桌面端布局(1024px+)已增强
  • 点击目标≥44px
  • 所有尺寸下文本可读
  • 无水平滚动
创意实现:
  • 独特美学(非通用模板)
  • 匹配指定设计方向
  • 有令人难忘的视觉元素
  • 视觉语言连贯
  • 细节打磨到位
代码质量:
  • TypeScript类型完整
  • 无代码检查错误
  • 遵循DRY原则
  • 组件边界清晰
  • 命名约定一致
  • 注释充足
  • 可直接投入生产(可部署)

Advanced Techniques

高级技巧

1. Fluid Typography

1. 流体排版

css
/* Responsive type scale using clamp() */
:root {
  --font-size-sm: clamp(0.875rem, 0.8rem + 0.2vw, 1rem);
  --font-size-base: clamp(1rem, 0.9rem + 0.3vw, 1.125rem);
  --font-size-lg: clamp(1.125rem, 1rem + 0.4vw, 1.25rem);
  --font-size-xl: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
  --font-size-2xl: clamp(1.5rem, 1.3rem + 0.7vw, 2rem);
  --font-size-3xl: clamp(1.875rem, 1.5rem + 1vw, 2.5rem);
  --font-size-4xl: clamp(2.25rem, 1.8rem + 1.5vw, 3.5rem);
}
css
/* 使用clamp()实现响应式排版刻度 */
:root {
  --font-size-sm: clamp(0.875rem, 0.8rem + 0.2vw, 1rem);
  --font-size-base: clamp(1rem, 0.9rem + 0.3vw, 1.125rem);
  --font-size-lg: clamp(1.125rem, 1rem + 0.4vw, 1.25rem);
  --font-size-xl: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
  --font-size-2xl: clamp(1.5rem, 1.3rem + 0.7vw, 2rem);
  --font-size-3xl: clamp(1.875rem, 1.5rem + 1vw, 2.5rem);
  --font-size-4xl: clamp(2.25rem, 1.8rem + 1.5vw, 3.5rem);
}

2. Advanced Color Systems

2. 高级颜色系统

css
/* Color with opacity variants using oklch */
:root {
  --primary-base: oklch(60% 0.15 250);
  --primary-subtle: oklch(95% 0.02 250);
  --primary-muted: oklch(85% 0.05 250);
  --primary-emphasis: oklch(50% 0.18 250);
  --primary-foreground: oklch(98% 0.01 250);
}

/* Dark mode: adjust lightness only */
[data-theme="dark"] {
  --primary-base: oklch(70% 0.15 250);
  --primary-subtle: oklch(20% 0.02 250);
  --primary-muted: oklch(30% 0.05 250);
  --primary-emphasis: oklch(80% 0.18 250);
  --primary-foreground: oklch(10% 0.01 250);
}
css
/* 使用oklch实现带透明度变体的颜色 */
:root {
  --primary-base: oklch(60% 0.15 250);
  --primary-subtle: oklch(95% 0.02 250);
  --primary-muted: oklch(85% 0.05 250);
  --primary-emphasis: oklch(50% 0.18 250);
  --primary-foreground: oklch(98% 0.01 250);
}

/* 深色模式:仅调整亮度 */
[data-theme="dark"] {
  --primary-base: oklch(70% 0.15 250);
  --primary-subtle: oklch(20% 0.02 250);
  --primary-muted: oklch(30% 0.05 250);
  --primary-emphasis: oklch(80% 0.18 250);
  --primary-foreground: oklch(10% 0.01 250);
}

3. Skeleton Loading Patterns

3. 骨架屏加载模式

tsx
// Animated skeleton with shimmer effect
const Skeleton = ({ className }: { className?: string }) => (
  <div
    className={cn(
      "animate-pulse rounded-md bg-surface-subtle",
      "relative overflow-hidden",
      "before:absolute before:inset-0",
      "before:-translate-x-full before:animate-shimmer",
      "before:bg-gradient-to-r before:from-transparent before:via-white/10 before:to-transparent",
      className
    )}
  />
);

// Usage in components
<Card>
  <Skeleton className="h-4 w-3/4 mb-2" />
  <Skeleton className="h-4 w-1/2 mb-4" />
  <Skeleton className="h-32 w-full" />
</Card>
tsx
// 带闪光效果的动画骨架屏
const Skeleton = ({ className }: { className?: string }) => (
  <div
    className={cn(
      "animate-pulse rounded-md bg-surface-subtle",
      "relative overflow-hidden",
      "before:absolute before:inset-0",
      "before:-translate-x-full before:animate-shimmer",
      "before:bg-gradient-to-r before:from-transparent before:via-white/10 before:to-transparent",
      className
    )}
  />
);

// 在组件中使用
<Card>
  <Skeleton className="h-4 w-3/4 mb-2" />
  <Skeleton className="h-4 w-1/2 mb-4" />
  <Skeleton className="h-32 w-full" />
</Card>

4. Advanced Motion

4. 高级动效

css
/* Page transitions */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered animations */
.stagger-item {
  animation: fade-in 0.3s ease-out backwards;
}
.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 50ms; }
.stagger-item:nth-child(3) { animation-delay: 100ms; }
.stagger-item:nth-child(4) { animation-delay: 150ms; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

css
/* 页面过渡 */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/*  stagger动画 */
.stagger-item {
  animation: fade-in 0.3s ease-out backwards;
}
.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 50ms; }
.stagger-item:nth-child(3) { animation-delay: 100ms; }
.stagger-item:nth-child(4) { animation-delay: 150ms; }

/* 尊重减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Tips for Excellence

卓越技巧

  1. Always start with tokens — Never skip to components
  2. Think mobile-first — Design for 375px, enhance upward
  3. Validate states early — Test each interactive state in isolation
  4. Be bold with aesthetics — Avoid generic patterns
  5. Accessibility is non-negotiable — Build it in from the start
  6. Use real content — Test with actual text, images, data
  7. Review your own work — Self-audit before delivering
  8. Document decisions — Explain complex styling choices
  9. Keep it maintainable — Future developers will thank you
  10. Ship production-ready code — No "TODO" or "FIXME" in deliverables

  1. 始终从令牌开始 — 绝不直接跳到组件开发
  2. 移动端优先思考 — 先为375px设计,再向上优化
  3. 尽早验证状态 — 单独测试每个交互状态
  4. 美学上要大胆 — 避免通用模式
  5. 无障碍是不可妥协的 — 从一开始就融入
  6. 使用真实内容 — 用实际文本、图片、数据测试
  7. 自我评审 — 交付前自行审核
  8. 记录决策 — 解释复杂的样式选择
  9. 保持可维护性 — 未来的开发者会感谢你
  10. 交付可直接生产的代码 — 交付成果中不要有「TODO」或「FIXME」

References & Resources

参考资源


Version: 2.0.0
Last Updated: December 2024
License: MIT
Maintained by: z-ai platform team

版本:2.0.0
最后更新:2024年12月
许可证:MIT
维护团队:z-ai平台团队