示例工程 27-design-tokens
27-design-tokens/app/tokens.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
/* 第一层:原始值。只描述色号,不描述用途 */
:root {
--blue-50: #eff6ff;
--blue-100: #dbeafe;
--blue-300: #93c5fd;
--blue-600: #2563eb;
--blue-700: #1d4ed8;
--blue-900: #1e3a8a;
--neutral-50: #f8fafc;
--neutral-100: #f1f5f9;
--neutral-200: #e2e8f0;
--neutral-400: #94a3b8;
--neutral-500: #64748b;
--neutral-700: #334155;
--neutral-800: #1e293b;
--neutral-900: #0f172a;
--red-400: #f87171;
--red-600: #dc2626;
/* 第二层:语义值。描述用途,引用原始值 */
--color-bg: var(--neutral-50);
--color-surface: #ffffff;
--color-text: var(--neutral-900);
--color-muted: var(--neutral-500);
--color-border: var(--neutral-200);
--color-primary: var(--blue-600);
--color-primary-strong: var(--blue-700);
--color-primary-soft: var(--blue-50);
--color-danger: var(--red-600);
--color-on-primary: #ffffff;
--color-on-danger: #ffffff;
/* 间距阶梯 */
--space-1: 0.25rem;
--space-2: 0.5rem;
--space-3: 0.75rem;
--space-4: 1rem;
--space-6: 1.5rem;
--space-8: 2rem;
--space-12: 3rem;
/* 字号阶梯 */
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.5rem;
--text-3xl: 2rem;
/* 圆角与阴影 */
--radius-sm: 0.375rem;
--radius-md: 0.75rem;
--radius-lg: 1rem;
--radius-full: 999px;
--shadow-sm: 0 1px 2px rgb(15 23 42 / 8%);
--shadow-md: 0 8px 24px rgb(15 23 42 / 12%);
}