This guide explains how to create Figma variable collections that generate WordPress block-level styles in theme.json.
WordPress theme.json allows you to define styles for specific blocks. This plugin supports creating block collections in Figma that export to the styles.blocks section of theme.json.
The plugin supports two patterns for organizing block styles:
Create a single wp.blocks collection and organize variables using Figma's group hierarchy:
Collection: wp.blocks
└── Group: core
├── cover
│ └── color/background
│ └── color/text
└── heading
└── color/text
Variable naming pattern: {namespace}/{block-name}/{property-path}
| Variable Name | Block Target | Property |
|---|---|---|
core/cover/color/background |
core/cover |
color.background |
core/heading/color/text |
core/heading |
color.text |
acf/hero/spacing/padding |
acf/hero |
spacing.padding |
Create separate collections for each block. Note: Figma interprets / in collection names as folder separators, which may cause issues.
wp.blocks.{namespace}/{block-name}
| Collection Name | Block Target |
|---|---|
wp.blocks.core/button |
WordPress core button block |
wp.blocks.core/paragraph |
WordPress core paragraph block |
wp.blocks.core/heading |
WordPress core heading block |
wp.blocks.acf/hero |
ACF custom hero block |
wp.blocks.theme/feature-card |
Theme custom feature card block |
WordPress core blocks use the core/ namespace. The plugin recognizes these and displays a blue "Core" badge in the UI.
Common core blocks:
core/button,core/buttonscore/paragraphcore/headingcore/image,core/gallerycore/list,core/list-itemcore/quote,core/pullquotecore/group,core/columns,core/columncore/cover,core/media-textcore/navigation,core/navigation-linkcore/query,core/post-templatecore/search
Any non-core namespace is treated as a custom block and displays a purple "Custom" badge.
Common namespaces:
acf/- Advanced Custom Fields blockstheme/- Theme-specific blocksplugin-name/- Plugin-provided blocks
Within a block collection, organize variables by their style category.
| Category | Description |
|---|---|
color |
Background, text, and gradient colors |
typography |
Font family, size, weight, style, line height |
spacing |
Padding, margin, block gap |
border |
Border color, radius, style, width |
shadow |
Box shadow |
dimensions |
Min height, aspect ratio |
filter |
Duotone filter |
outline |
Outline properties |
{category}/{property}
{category}/{subcategory}/{property}
:{pseudo-selector}/{category}/{property}
Blocks support the following pseudo-selectors:
| Selector | Usage |
|---|---|
:hover |
Mouse hover state |
:focus |
Keyboard focus state |
:active |
Active/pressed state |
Collection: wp.blocks.core/button
Variables:
color/background → Default background
color/text → Default text color
:hover/color/background → Hover background
:hover/color/text → Hover text color
:focus/color/background → Focus background
:focus/outline/color → Focus outline color
:active/color/background → Active/pressed background
Blocks can contain nested element styles using the elements/ prefix.
elements/{element-name}/{category}/{property}
Collection: wp.blocks.core/button
Variables:
color/background → Block background
elements/link/color/text → Link text color inside button
elements/link/:hover/color/text → Link hover color
Output:
{
"styles": {
"blocks": {
"core/button": {
"color": {
"background": "#0073aa"
},
"elements": {
"link": {
"color": {
"text": "#ffffff"
},
":hover": {
"color": {
"text": "#cccccc"
}
}
}
}
}
}
}
}Variables in Figma:
color/background
color/text
typography/fontSize
typography/fontWeight
spacing/padding/top
spacing/padding/right
spacing/padding/bottom
spacing/padding/left
border/radius
:hover/color/background
:hover/color/text
:focus/outline/color
:focus/outline/width
:focus/outline/offset
{
"styles": {
"blocks": {
"core/button": {
"color": {
"background": "#0073aa",
"text": "#ffffff"
},
"typography": {
"fontSize": "16px",
"fontWeight": "600"
},
"spacing": {
"padding": {
"top": "12px",
"right": "24px",
"bottom": "12px",
"left": "24px"
}
},
"border": {
"radius": "4px"
},
":hover": {
"color": {
"background": "#005a87",
"text": "#ffffff"
}
},
":focus": {
"outline": {
"color": "#005a87",
"width": "2px",
"offset": "2px"
}
}
}
}
}
}For color values, you can reference WordPress palette presets:
Create a variable alias that references your color palette:
color/background → alias to wp.settings.colors/primary
When exporting, choose the color export mode:
- Use color values: Exports resolved hex values
- Use palette preset references: Exports
var:preset|color|{slug}references
{
"styles": {
"blocks": {
"core/button": {
"color": {
"background": "var:preset|color|primary",
"text": "var:preset|color|white"
}
}
}
}
}The plugin automatically detects all wp.blocks.* collections and displays them in the "Detected Blocks" section of the Configure step.
- Blue "Core" badge: WordPress core blocks (
core/*) - Purple "Custom" badge: Custom/third-party blocks
Click the "Detected Blocks" header to expand or collapse the list.
-
Match WordPress block names exactly: Use the correct namespace and block name as registered in WordPress
-
Use semantic color references: Reference your color palette variables instead of hardcoding hex values
-
Test in WordPress: Validate that your block styles apply correctly in the block editor
-
Consider cascade: Block styles override global and element styles, so use them intentionally
-
Group related blocks: Consider creating a naming convention for your custom blocks (e.g.,
theme/hero,theme/testimonial)
The plugin validates block collection names and will display warnings for:
- Invalid block name format (missing namespace or block name)
- Invalid pseudo-selectors
Warnings are non-blocking - export continues but you're informed of potential issues.
- Naming Conventions - Complete naming reference
- Elements Guide - Element-level styling
- Color Presets Guide - Color palette configuration