视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
design-systems设计系统架构和 design tokens。涵盖 W3C Design Token 规范、atomic design 方法论、组件文档、主题化、深色/浅色模式,以及现代 CSS 自定义属性模式。 USE WHEN: 用户提到 "design system", "design tokens", "component library", "theming", "dark mode", "light mode", "CSS variables", "atomic design", "color palet…"
AI 翻译
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: design-systems description: | Design system architecture and design tokens. Covers W3C Design Token spec, atomic design methodology, component documentation, theming, dark/light mode, and modern CSS custom property patterns.
USE WHEN: user mentions "design system", "design tokens", "component library", "theming", "dark mode", "light mode", "CSS variables", "atomic design", "color palette", "token architecture", "shadcn theming", "brand tokens"
The W3C Design Tokens Community Group spec defines a vendor-neutral JSON format for sharing design decisions across tools (Figma, Sketch, Style Dictionary, Tokens Studio).
{
"color": {
"brand": {
"$type": "color",
"primary": { "$value": "#2563eb", "$description": "Primary brand blue" },
"primary-hover": { "$value": "#1d4ed8" },
"secondary": { "$value": "#7c3aed" }
},
"neutral": {
"$type": "color",
"50": { "$value": "#f8fafc" },
"100": { "$value": "#f1f5f9" },
"500": { "$value": "#64748b" },
"900": { "$value": "#0f172a" }
}
},
"spacing": {
"$type": "dimension",
"4": { "$value": "1rem" },
"8": { "$value": "2rem" },
"12": { "$value": "3rem" }
},
"font-size": {
"$type": "dimension",
"base": { "$value": "1rem" },
"lg": { "$value": "1.125rem" }
},
"border-radius": {
"$type": "dimension",
"sm": { "$value": "0.25rem" },
"md": { "$value": "0.375rem" },
"lg": { "$value": "0.5rem" },
"full": { "$value": "9999px" }
}
}
Primitive tokens → Semantic tokens → Component tokens
─────────────────────────────────────────────────────────────────
color.neutral.900 color.text.primary button.text.color
color.brand.primary color.interactive.default button.bg.default
spacing.4 spacing.component.padding input.padding
Rule: Components consume semantic tokens, never primitives directly. This enables theming by swapping the semantic layer.
shadcn uses HSL values without the hsl() wrapper, enabling opacity modifiers (bg-background/80):
:root {
--background: 0 0% 100%; /* white */
--foreground: 222.2 47.4% 11.2%;
--card: 0 0% 100%;
--card-foreground: 222.2 47.4% 11.2%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 47.4% 11.2%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 47.4% 11.2%;
--radius: 0.5rem;
}
.dark {
--background: 224 71% 4%;
--foreground: 213 31% 91%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 1.2%;
--muted: 223 47% 11%;
--muted-foreground: 215.4 16.3% 56.9%;
--border: 216 34% 17%;
--input: 216 34% 17%;
}
Usage in Tailwind: bg-background, text-foreground, border-border, bg-primary/80.
// ThemeProvider — respects system, allows manual override
type Theme = "light" | "dark" | "system";
function applyTheme(theme: Theme) {
const root = document.documentElement;
const isDark =
theme === "dark" ||
(theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches);
root.classList.toggle("dark", isDark);
root.setAttribute("data-theme", isDark ? "dark" : "light");
}
// Watch for system changes
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
mediaQuery.addEventListener("change", () => {
if (currentTheme === "system") applyTheme("system");
});
<!-- In <head> — prevents flash of wrong theme -->
<script>
const theme = localStorage.getItem("theme") || "system";
const isDark = theme === "dark" ||
(theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches);
document.documentElement.classList.toggle("dark", isDark);
</script>
| Level | Description | shadcn/Radix equivalent | Example |
|---|---|---|---|
| Atoms | Smallest UI elements | Button, Input, Badge, Avatar | <Button variant="outline"> |
| Molecules | 2–3 atoms combined | FormField (Label + Input + Error), SearchBar | <FormField> |
| Organisms | Complex sections | DataTable, Header, Sidebar | <Table> with toolbar |
| Templates | Page-level layout skeleton | DashboardLayout, AuthLayout | Layout with slots |
| Pages | Fully assembled with real content | DashboardPage, ProfilePage | Complete screen |
Note: Few teams follow Atomic Design strictly. Use it as a mental model for deciding where a component belongs, not as a rigid rule.
Style Dictionary transforms design token JSON into platform-specific outputs (CSS variables, Sass, iOS, Android).
// style-dictionary.config.js
import StyleDictionary from "style-dictionary";
export default {
source: ["tokens/**/*.json"],
platforms: {
css: {
transformGroup: "css",
prefix: "ds",
buildPath: "dist/",
files: [
{
destination: "tokens.css",
format: "css/variables",
options: { outputReferences: true },
},
],
},
js: {
transformGroup: "js",
buildPath: "dist/",
files: [{ destination: "tokens.js", format: "javascript/es6" }],
},
},
};
styling/shadcn-ui — component usage and customizationstyling/radix-ui — headless primitive compositionstyling/tailwindcss — utility implementation layerux/visual-hierarchy — type scale and spacing foundationux/interaction-design — animation tokens (duration, easing)Load via mcp__documentation__fetch_docs:
ux-design-systems — W3C token spec details, Style Dictionary advanced config, atomic design extended guide