Design-Token-Verwaltung mit Claude Code: Leitfaden für konsistente UI
Design-Token-Verwaltung mit Claude Code. Leitfaden für konsistente UI. Mit praktischen Codebeispielen.
Design-Token-Verwaltung mit Claude Code optimieren
Design-Tokens sind ein System zur zentralen Verwaltung von Designentscheidungen wie Farben, Typografie und Abständen. Mit Claude Code können Sie von der Token-Definition bis zur Code-Generierung effizient aufbauen.
Token-Definition
JSON-basiertes Token-Design
> Definiere Design-Tokens gemäß der W3C Design Tokens Community Group-Spezifikation.
> Einschließlich Farben, Typografie, Abstände und Radien.
{
"color": {
"primary": {
"50": { "$value": "#eff6ff", "$type": "color" },
"100": { "$value": "#dbeafe", "$type": "color" },
"500": { "$value": "#3b82f6", "$type": "color" },
"600": { "$value": "#2563eb", "$type": "color" },
"700": { "$value": "#1d4ed8", "$type": "color" },
"900": { "$value": "#1e3a8a", "$type": "color" }
},
"semantic": {
"background": {
"default": { "$value": "{color.primary.50}", "$type": "color" },
"inverse": { "$value": "{color.primary.900}", "$type": "color" }
},
"text": {
"default": { "$value": "#1a1a1a", "$type": "color" },
"muted": { "$value": "#6b7280", "$type": "color" },
"inverse": { "$value": "#ffffff", "$type": "color" }
}
}
},
"typography": {
"fontSize": {
"xs": { "$value": "0.75rem", "$type": "dimension" },
"sm": { "$value": "0.875rem", "$type": "dimension" },
"base": { "$value": "1rem", "$type": "dimension" },
"lg": { "$value": "1.125rem", "$type": "dimension" },
"xl": { "$value": "1.25rem", "$type": "dimension" },
"2xl": { "$value": "1.5rem", "$type": "dimension" }
},
"fontWeight": {
"normal": { "$value": "400", "$type": "fontWeight" },
"medium": { "$value": "500", "$type": "fontWeight" },
"bold": { "$value": "700", "$type": "fontWeight" }
}
},
"spacing": {
"1": { "$value": "0.25rem", "$type": "dimension" },
"2": { "$value": "0.5rem", "$type": "dimension" },
"4": { "$value": "1rem", "$type": "dimension" },
"8": { "$value": "2rem", "$type": "dimension" },
"16": { "$value": "4rem", "$type": "dimension" }
},
"radius": {
"sm": { "$value": "0.25rem", "$type": "dimension" },
"md": { "$value": "0.375rem", "$type": "dimension" },
"lg": { "$value": "0.5rem", "$type": "dimension" },
"full": { "$value": "9999px", "$type": "dimension" }
}
}
Code-Generierung mit Style Dictionary
Multiplattform-Ausgabe
> Erstelle eine Style Dictionary-Konfiguration.
> Ausgabe als CSS-Variablen, TypeScript-Konstanten und für iOS/Android.
// style-dictionary.config.js
import StyleDictionary from 'style-dictionary';
export default {
source: ['tokens/**/*.json'],
platforms: {
css: {
transformGroup: 'css',
buildPath: 'dist/css/',
files: [{
destination: 'variables.css',
format: 'css/variables',
options: { outputReferences: true },
}],
},
typescript: {
transformGroup: 'js',
buildPath: 'dist/ts/',
files: [{
destination: 'tokens.ts',
format: 'javascript/es6',
}],
},
ios: {
transformGroup: 'ios-swift',
buildPath: 'dist/ios/',
files: [{
destination: 'StyleDictionary.swift',
format: 'ios-swift/class.swift',
}],
},
},
};
Generierte CSS-Variablen:
:root {
--color-primary-500: #3b82f6;
--color-primary-600: #2563eb;
--color-semantic-text-default: #1a1a1a;
--spacing-4: 1rem;
--radius-md: 0.375rem;
}
Dark-Mode-Unterstützung
Mit semantischen Tokens ist auch die Dark-Mode-Unterstützung einfach.
[data-theme="dark"] {
--color-semantic-background-default: var(--color-primary-900);
--color-semantic-text-default: #f3f4f6;
}
Figma-Integration
Auch die Synchronisation von Figma Variables mit Design-Token-JSON kann mit Claude Code besprochen werden. Die Generierung von Token-Extraktionsskripten über die Figma REST API ist ebenfalls möglich.
Zusammenfassung
Mit Claude Code können Sie effizient von der Design-Token-Definition über die Code-Generierung mit Style Dictionary bis zur Multiplattform-Unterstützung aufbauen. Siehe auch Design-System aufbauen, CSS/Styling-Leitfaden und Dark-Mode-Implementierung.
Details zu Style Dictionary finden Sie in der offiziellen Style Dictionary-Dokumentation.
Related Posts
So beschleunigen Sie Ihre Nebenprojekte mit Claude Code [Mit Beispielen]
Erfahren Sie, wie Sie persönliche Entwicklungsprojekte mit Claude Code drastisch beschleunigen. Inklusive realer Beispiele und eines praktischen Workflows von der Idee bis zum Deployment.
So automatisieren Sie Refactoring mit Claude Code
Erfahren Sie, wie Sie Code-Refactoring mit Claude Code effizient automatisieren. Inklusive praktischer Prompts und konkreter Refactoring-Muster für reale Projekte.
Vollständiger CORS-Konfigurationsleitfaden mit Claude Code
Erfahren Sie alles über die CORS-Konfiguration mit Claude Code. Mit praktischen Tipps und Codebeispielen.