Skip to content

pantoken / packages/core/src / buildTokens

Function: buildTokens()

buildTokens(options?): Token[]

Beta

Build the canonical token IR for a theme: primitives, layout, semantic colours, component tokens, and optional icons, then run plugin icon and token hooks over the result.

Parameters

options?

BuildTokensOptions = {}

BuildTokensOptions.

Returns

Token[]

The resolved, de-duplicated Token list.

Examples

Build the default (rebrand) IR

ts
import { buildTokens } from "@pantoken/core";

const tokens = buildTokens();
// → Token[] : { name, syntax, inherits, value, themed?, refersTo?, meta? }

Pick a theme and drop the icon layer

ts
import { buildTokens } from "@pantoken/core";

// A smaller, colour/layout-only IR for the canvas theme.
const tokens = buildTokens({ theme: "canvas", includeIcons: false });

Run a plugin's tokens hook over the IR

ts
import { buildTokens, type PantokenPlugin } from "@pantoken/core";

const brand: PantokenPlugin = {
  name: "brand",
  tokens: ({ tokens, define }) => [
    ...tokens,
    define({ name: "--instui-focus-color", value: "var(--instui-color-border-brand)" }),
  ],
};

buildTokens({ theme: "rebrand", plugins: [brand] });