How to Add a Style Variation to a WordPress Block Theme

A site owner may want a warmer seasonal look or a higher-contrast colour scheme without switching themes or rebuilding every page. A block theme can offer a selectable style variation: a JSON file that changes global settings and styles while leaving the theme’s templates in place.

This guide is for theme developers working with a block theme. It shows the file placement and a small example, then explains how to test the variation without treating it like a separate theme or assuming every user-created style will be overwritten.

Editorial illustration showing a WordPress block theme switching between two style variation JSON files

Editorial illustration: alternate style JSON files change the visual system while the block theme’s templates remain.

Summary

  • Put each global style variation in a JSON file under the block theme’s styles/ directory.
  • Use the same supported theme.json structure for the settings and styles you want to vary.
  • Test in the Site Editor and on the front end; a variation is a starting style, not a guaranteed replacement for user customizations.

What a style variation changes

A global style variation is a named alternative to the theme’s default design settings and styles. It is distinct from a block style variation, which adds an appearance choice to one block, and from a block variation, which changes a block’s configuration or presentation. The similar names cause confusion, so decide whether you want to recolour a whole site or add an option to a specific block.

For a global style variation, the theme supplies another JSON configuration. It does not create new templates or change the theme’s PHP and block markup. That makes it a practical way to give a site editor a controlled visual starting point.

Add a variation file

In a block theme, create a file such as styles/soft-sand.json. A minimal example could look like this:

{
  "$schema": "https://schemas.wp.org/wp/6.6/theme.json",
  "version": 3,
  "title": "Soft Sand",
  "styles": {
    "color": {
      "background": "#f5f0e6",
      "text": "#25231f"
    },
    "typography": {
      "fontFamily": "var(--wp--preset--font-family--system)"
    },
    "elements": {
      "button": {
        "color": {
          "background": "#274b45",
          "text": "#ffffff"
        }
      }
    }
  }
}

The $schema URL should match the WordPress version your theme supports; use the schema and version appropriate to that support range. Save the file inside the active theme’s styles/ folder, alongside any other variations. Use colour and font presets defined by the theme where possible, so the variation stays coherent when the base design changes.

The title is the human-readable name shown to editors. The filename becomes the variation slug. Keep it short and stable because it identifies the option in the theme interface. WordPress recognizes variations from the theme’s styles directory; this is not the same as placing another theme.json at the root.

Test it in a safe sequence

  1. Make the change in a development checkout or staging site using the same WordPress version as production.
  2. Confirm the active theme is a block theme and that the JSON parses. A missing comma can prevent the variation from appearing.
  3. Open Appearance → Editor → Styles and locate the variation. The precise interface can differ by WordPress version.
  4. Apply it, then inspect the home page, posts, navigation, buttons, forms and any custom templates.
  5. Check both editor preview and the public front end at desktop and mobile widths.
  6. Revisit the default style and confirm the theme still looks correct without the variation.

A variation can look polished on the home page but produce unreadable button text or awkward contrast elsewhere. Check text, focus states and components that use theme presets, not just the palette preview.

Understand the editing trade-off

Offering variations gives site owners an easy choice, but it also increases the combinations a theme author needs to support. A user may apply a variation and then make custom changes in Global Styles. The resulting saved site styles can differ from the theme’s original JSON. Do not promise that changing a theme file later will reset every site to the variation’s new values.

For a major redesign, a variation may be too limited. If layouts, templates or block composition must change, provide a separate template or pattern, or consider whether a different theme is more honest. Keep variations focused on styling rather than hiding structural changes inside an alternative palette.

Common mistakes

  • Putting a global variation in the root instead of the styles/ directory.
  • Confusing global style variations with per-block style variations.
  • Using preset names that the theme never defines.
  • Testing only in the editor and not on the rendered site.
  • Omitting contrast and mobile checks.
  • Treating a variation as a reliable way to overwrite a user’s saved Global Styles changes.

My Take

A style variation is most useful when it expresses a genuinely different mood with a small number of consistent tokens: background, text, accent and component colours. If each option needs a different layout or extensive overrides, the theme is asking one mechanism to do too much. Start with a restrained alternative and let users decide whether it solves a real design need.

For a runtime styling decision rather than a theme-wide palette, see how WordPress handles inline styles and right-to-left stylesheets. If you are tuning page assets, review image alt text in the editor.

Conclusion

Add a JSON file under a block theme’s styles/ directory, use the correct theme.json schema for your supported WordPress versions, and test the option across templates and components. A variation gives editors a convenient visual starting point while keeping one theme and one template system.

Sources