As WordPress evolves into a full-site editing and headless-ready platform, maintaining a consistent design language becomes increasingly complex – but also more crucial. Whether you’re designing custom blocks, working in a headless frontend, or building reusable components, design tokens are the foundation of visual consistency.
In this guide, you’ll learn how to use design tokens in WordPress to create modular, scalable, and unified UI components, and how to integrate them with tools like Figma, Style Dictionary, and theme.json.
What Are Design Tokens?
Design tokens are platform-agnostic variables that store visual style attributes – like color, spacing, font size, or border radius – in a single source of truth. Instead of hardcoding styles, tokens allow you to define values once and apply them consistently across themes, plugins, and components.
Example:
{
"color": {
"primary": "#0073aa",
"secondary": "#23282d"
},
"font": {
"base": "16px",
"heading": "24px"
}
}
Tokens like these can be consumed by CSS, JavaScript, PHP, and WordPress configuration files.
Why Use Design Tokens in WordPress?
✅ Consistency – Eliminate visual drift across blocks, templates, and themes
🎯 Scalability – Change a brand color or font size globally by updating a token
🧱 Component-based design – Reuse styles across multiple components
🛠 Tool integration – Connect design and development via Figma, Style Dictionary, and theme.json
Using Design Tokens in WordPress Themes
Integrating Tokens with theme.json
WordPress’s theme.json
is the ideal place to manage your design tokens for block-based themes. It enables you to define colors, typography, and spacing globally.
Example:
{
"settings": {
"color": {
"palette": [
{
"slug": "primary",
"color": "#0073aa",
"name": "Primary"
}
]
},
"typography": {
"fontSizes": [
{
"slug": "heading",
"size": "24px",
"name": "Heading"
}
]
}
}
}
These values automatically power Gutenberg’s visual controls and editor preview styles.
Applying Tokens in CSS Components
Once tokens are mapped in theme.json
, WordPress outputs them as CSS variables like:
.button-primary {
background-color: var(--wp--preset--color--primary);
font-size: var(--wp--preset--font-size--heading);
padding: 0.5rem 1rem;
}
From Figma to WordPress: Automating Token Workflows
Design tools like Figma and Token Studio allow you to define and export tokens into usable formats (JSON, SCSS, CSS).
Example Workflow:
- 🎨 Define tokens in Figma using Token Studio
- 📤 Export tokens as JSON
- ⚙️ Use Style Dictionary to convert tokens into multiple outputs:
theme.json
- CSS variables
- SCSS mixins
style-dictionary build --config style-dictionary.config.js
This keeps your design system and WordPress codebase in sync—especially useful for teams collaborating across design and development.
Component Libraries with Tokens
In a React- or Vue-based component library (e.g., Next.js frontend or block editor extensions), design tokens can be injected via props or CSS variables.
Example React button using tokens:
const Button = ({ label }) => (
<button style={{
backgroundColor: 'var(--token-color-primary)',
fontSize: 'var(--token-font-base)'
}}>
{label}
</button>
);
Define global variables:
:root {
--token-color-primary: #0073aa;
--token-font-base: 16px;
}
Use tokens consistently across JavaScript, CSS, and PHP-rendered blocks.
Code Examples
Button with Design Tokens (CSS + JS)
const Button = ({ type = "primary", children }) => {
const className = `btn btn-${type}`;
return <button className={className}>{children}</button>;
};
:root {
--color-primary: #0073aa;
--font-base: 16px;
}
.btn-primary {
background-color: var(--color-primary);
font-size: var(--font-base);
color: #fff;
padding: 0.5rem 1rem;
}
Custom Spacing Tokens in theme.json
{
"settings": {
"spacing": {
"spacingScale": {
"small": "0.5rem",
"medium": "1rem",
"large": "2rem"
},
"units": ["px", "em", "rem"]
}
}
}
Best Practices for Design Tokens in WordPress
- Use naming conventions: Prefer
color.primary
,spacing.medium
, etc. - Version control token files: Store tokens as JSON or SCSS in Git.
- Automate token transformation: Use tools like Gulp or Style Dictionary.
- Keep tokens DRY: Reuse values instead of duplicating them.
- Use CSS variables: Enable runtime theming and environment-specific overrides.
Conclusion
Design tokens are a powerful tool to unify design and development. In WordPress, they enable:
- ✅ Consistent, reusable UI components
- 🎨 Cohesive styling across block themes, plugins, and headless setups
- 🚀 Faster development and design-to-code workflows
As WordPress embraces modern, component-based architectures, design tokens in WordPress will become an essential foundation for scalable, maintainable sites.
How Sitebox Supports Design Tokens
Sitebox is built for developers and designers working in modern WordPress and headless environments. Here’s how it simplifies design token management:
- 🎨 Sync design tokens directly from Figma
- ⚙️ Generate
theme.json
and CSS variables automatically - 💡 Use tokens in custom Gutenberg blocks and React components
- 🔄 Inject tokens at build time and runtime for full flexibility
👉 Explore Sitebox’s design token features