This guide explains how to create Figma variable collections that generate WordPress element-level styles in theme.json.
WordPress theme.json allows you to define styles for HTML elements across your entire theme. This plugin supports creating element collections in Figma that export to the styles.elements section of theme.json.
Element collections must follow this naming convention:
wp.elements.{element-name}
Or create a single collection for all elements:
wp.elements
WordPress theme.json v3 supports the following elements:
| Element | Description |
|---|---|
button |
Button elements and button-styled links |
link |
Anchor (<a>) elements |
heading |
All heading levels (h1-h6) |
h1 |
Heading level 1 |
h2 |
Heading level 2 |
h3 |
Heading level 3 |
h4 |
Heading level 4 |
h5 |
Heading level 5 |
h6 |
Heading level 6 |
caption |
Caption elements |
cite |
Citation elements |
code |
Code/preformatted elements |
Create one collection wp.elements and organize by element:
button/color/background
button/color/text
button/:hover/color/background
link/color/text
link/:hover/color/text
heading/typography/fontFamily
h1/typography/fontSize
h2/typography/fontSize
Create individual collections:
wp.elements.buttonwp.elements.linkwp.elements.heading
Variables in wp.elements.button:
color/background
color/text
:hover/color/background
:hover/color/text
Different elements support different pseudo-selectors:
| Selector | Description |
|---|---|
:hover |
Mouse hover state |
:focus |
Keyboard focus state |
:active |
Active/pressed state |
| Selector | Description |
|---|---|
:visited |
Visited link state |
:link |
Unvisited link state |
Collection: wp.elements.link
Variables:
color/text → Default link color
:hover/color/text → Hover state
:focus/color/text → Focus state
:active/color/text → Active/pressed state
:visited/color/text → Visited link color
:link/color/text → Unvisited link color
Elements support the following style categories:
| Category | Properties |
|---|---|
color |
background, text, gradient |
typography |
fontFamily, fontSize, fontWeight, fontStyle, lineHeight, letterSpacing, textDecoration, textTransform |
spacing |
padding, margin (with top, right, bottom, left) |
border |
color, radius, style, width (with directional variants) |
shadow |
Box shadow value |
outline |
color, offset, style, width |
Collection: wp.elements.button
Variables:
color/background
color/text
typography/fontSize
typography/fontWeight
typography/fontFamily
spacing/padding/top
spacing/padding/right
spacing/padding/bottom
spacing/padding/left
border/radius
border/width
border/style
border/color
:hover/color/background
:hover/color/text
:hover/border/color
:focus/outline/color
:focus/outline/width
:focus/outline/offset
Output:
{
"styles": {
"elements": {
"button": {
"color": {
"background": "#0073aa",
"text": "#ffffff"
},
"typography": {
"fontSize": "16px",
"fontWeight": "600",
"fontFamily": "var(--wp--preset--font-family--system)"
},
"spacing": {
"padding": {
"top": "12px",
"right": "24px",
"bottom": "12px",
"left": "24px"
}
},
"border": {
"radius": "4px",
"width": "0px",
"style": "solid",
"color": "transparent"
},
":hover": {
"color": {
"background": "#005a87",
"text": "#ffffff"
},
"border": {
"color": "transparent"
}
},
":focus": {
"outline": {
"color": "#005a87",
"width": "2px",
"offset": "2px"
}
}
}
}
}
}Collection: wp.elements.link
Variables:
color/text
typography/textDecoration
:hover/color/text
:hover/typography/textDecoration
:focus/color/text
:focus/outline/color
:visited/color/text
Output:
{
"styles": {
"elements": {
"link": {
"color": {
"text": "#0073aa"
},
"typography": {
"textDecoration": "underline"
},
":hover": {
"color": {
"text": "#005a87"
},
"typography": {
"textDecoration": "none"
}
},
":focus": {
"color": {
"text": "#005a87"
},
"outline": {
"color": "#005a87"
}
},
":visited": {
"color": {
"text": "#551a8b"
}
}
}
}
}
}Collection: wp.elements (single collection approach)
Variables:
heading/typography/fontFamily
heading/typography/fontWeight
heading/typography/lineHeight
h1/typography/fontSize
h2/typography/fontSize
h3/typography/fontSize
h4/typography/fontSize
h5/typography/fontSize
h6/typography/fontSize
Output:
{
"styles": {
"elements": {
"heading": {
"typography": {
"fontFamily": "var(--wp--preset--font-family--heading)",
"fontWeight": "700",
"lineHeight": "1.2"
}
},
"h1": {
"typography": {
"fontSize": "48px"
}
},
"h2": {
"typography": {
"fontSize": "36px"
}
},
"h3": {
"typography": {
"fontSize": "28px"
}
},
"h4": {
"typography": {
"fontSize": "24px"
}
},
"h5": {
"typography": {
"fontSize": "20px"
}
},
"h6": {
"typography": {
"fontSize": "16px"
}
}
}
}
}For color values, you can reference WordPress palette presets.
In the Configure step, choose the "Elements color export" mode:
- Use color values: Exports resolved hex values (e.g.,
#0073aa) - Use palette preset references: Exports WordPress references (e.g.,
var:preset|color|primary)
With color values:
{
"color": {
"text": "#0073aa"
}
}With preset references:
{
"color": {
"text": "var:preset|color|primary"
}
}When you have button color variants in your wp.elements.button collection (e.g., secondary, tertiary), the plugin automatically generates button style variation files.
The plugin detects these button variant names:
secondarytertiaryoutlineghostlinkdestructive
In wp.elements.button:
color/button/primary/default/background
color/button/primary/hover/background
color/button/secondary/default/background
color/button/secondary/hover/background
color/button/tertiary/default/background
color/button/tertiary/hover/background
The plugin generates separate style files:
styles/button-secondary.jsonstyles/button-tertiary.json
These are WordPress block style variations that can be selected in the block editor.
The plugin validates element names and pseudo-selectors. You'll see warnings for:
- Unknown element names (not in the valid list)
- Invalid pseudo-selectors
- Using
:visitedor:linkon non-link elements
Warnings are non-blocking - export continues but you're informed of potential issues.
-
Start with
headingfor base styles: Define common heading styles inheading, then override specific levels inh1,h2, etc. -
Consider accessibility: Always define
:focusstyles for interactive elements -
Use semantic colors: Reference your color palette instead of hardcoding values
-
Test link states: Ensure
:visitedlinks are still readable -
Mind the cascade: Element styles apply globally - use blocks for specific components
-
Use
buttonsorbutton: The plugin normalizeswp.elements.buttonstobuttonautomatically
- Naming Conventions - Complete naming reference
- Blocks Guide - Block-level styling
- Color Presets Guide - Color palette configuration