style-dictionary
БесплатноБез исполняемых скриптовНе проверенTransforms design tokens into platform-specific formats (CSS, SCSS, iOS Swift, Android XML). Use when setting up multi-platform token pipelines, creating…
Об этом скилле
Style Dictionary
Overview
Set up Style Dictionary to transform design tokens into platform-specific formats. The industry standard for design systems that need to output to web, iOS, Android, and other platforms from a single token source.
When to Use
- Setting up a new design system with multi-platform needs
- Converting Figma tokens to code
- Generating CSS, SCSS, iOS Swift, Android XML from one source
- Adding custom token transforms or formats
- Integrating tokens into a build pipeline
Quick Reference: Core Concepts
| Concept | Purpose | Example |
|---|---|---|
| Token | Design value with metadata | { "value": "#3b82f6", "type": "color" } |
| Transform | Converts token values | color/hex → color/rgb |
| Format | Outputs to file type | CSS variables, Swift, XML |
| Platform | Target environment | web, ios, android |
The Process
- Assess token sources: Where are tokens defined? (Figma, JSON, YAML)
- Identify platforms: Which platforms need tokens?
- Set up config: Create
style-dictionary.config.js - Define transforms: Add any custom value transformations
- Build: Run
style-dictionary build
Implementation Checklist
Copy this checklist when setting up Style Dictionary:
Style Dictionary Setup:
- [ ] Install: `npm install style-dictionary`
- [ ] Create tokens/ directory with source JSON files
- [ ] Create style-dictionary.config.js with source paths and platform outputs
- [ ] Add build script to package.json: `"tokens:build": "style-dictionary build"`
- [ ] Run build and verify output files are generated correctly
Project Setup
Installation
npm install style-dictionary
# or
yarn add style-dictionary
Directory Structure
tokens/
├── base/
│ ├── colors.json
│ ├── spacing.json
│ └── typography.json
├── semantic/
│ ├── colors.json
│ └── components.json
└── themes/
├── light.json
└── dark.json
build/ # Generated output
├── css/
│ └── variables.css
├── ios/
│ └── StyleDictionary.swift
└── android/
└── colors.xml
style-dictionary.config.js
Configuration
Basic Config
// style-dictionary.config.js
module.exports = {
source: ['tokens/**/*.json'],
platforms: {
css: {
transformGroup: 'css',
buildPath: 'build/css/',
files: [
{
destination: 'variables.css',
format: 'css/variables',
},
],
},
},
};
Multi-Platform Config
// style-dictionary.config.js
module.exports = {
source: ['tokens/**/*.json'],
platforms: {
// Web - CSS Custom Properties
css: {
transformGroup: 'css',
buildPath: 'build/css/',
files: [
{
destination: 'variables.css',
format: 'css/variables',
options: {
outputReferences: true, // Keep token references
},
},
],
},
// Web - SCSS Variables
scss: {
transformGroup: 'scss',
buildPath: 'build/scss/',
files: [
{
destination: '_variables.scss',
format: 'scss/variables',
},
],
},
// Web - JavaScript/TypeScript
js: {
transformGroup: 'js',
buildPath: 'build/js/',
files: [
{
destination: 'tokens.js',
format: 'javascript/es6',
},
{
destination: 'tokens.d.ts',
format: 'typescript/es6-declarations',
},
],
},
// iOS - Swift
ios: {
transformGroup: 'ios-swift',
buildPath: 'build/ios/',
files: [
{
destination: 'StyleDictionary.swift',
format: 'ios-swift/class.swift',
className: 'StyleDictionary',
},
],
},
// Android - XML Resources
android: {
transformGroup: 'android',
buildPath: 'build/android/',
files: [
{
destination: 'colors.xml',
format: 'android/colors',
filter: { type: 'color' },
},
{
destination: 'dimens.xml',
format: 'android/dimens',
filter: { type: 'dimension' },
},
],
},
},
};
Token Format
Design Tokens Community Group (DTCG) Format
{
"color": {
"primary": {
"$value": "#3b82f6",
"$type": "color",
"$description": "Primary brand color"
},
"secondary": {
"$value": "#64748b",
"$type": "color"
}
},
"spacing": {
"sm": {
"$value": "8px",
"$type": "dimension"
},
"md": {
"$value": "16px",
"$type": "dimension"
}
}
}
Style Dictionary Classic Format
{
"color": {
"primary": {
"value": "#3b82f6",
"type": "color",
"comment": "Primary brand color"
}
},
"spacing": {
"sm": { "value": "8px" },
"md": { "value": "16px" }
}
}
Token References (Aliases)
{
"color":
Установить style-dictionary в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл style-dictionary?
Transforms design tokens into platform-specific formats (CSS, SCSS, iOS Swift, Android XML). Use when setting up multi-platform token pipelines, creating build processes, or managing cross-platform design systems.
Как установить скилл style-dictionary?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл style-dictionary запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic