Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Function: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Experimental

Convert an IR token list into a WordPress theme.json.

Parameters

tokens

readonly Token[]

The IR (e.g. from @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Returns

ThemeJson

A theme.json document.

Examples

Convert an IR to a light-mode theme.json

ts
import { toThemeJson } from "@pantoken/wordpress";
import { byTheme } from "@pantoken/tokens";

const doc = toThemeJson(byTheme("rebrand"));
doc.settings.color.palette; // [{ slug, name, color }, …]

Dark mode

ts
import { toThemeJson } from "@pantoken/wordpress";
import { byTheme } from "@pantoken/tokens";

const doc = toThemeJson(byTheme("canvas"), { mode: "dark" });