Skip to content

pantoken-root / packages/core/src / runTokenPlugins

Function: runTokenPlugins() ​

runTokenPlugins(tokens, theme, plugins): Token[]

Beta

Run every plugin's tokens hook in order. Each hook receives the current list and returns the full replacement; the result is de-duplicated by name.

Parameters ​

tokens ​

Token[]

theme ​

Theme

plugins ​

readonly PantokenPlugin[]

Returns ​

Token[]

Example ​

ts
import { runTokenPlugins, type PantokenPlugin } from "@pantoken/core";
import type { Token } from "@pantoken/model";

const base: Token[] = [
  { name: "--instui-x", syntax: "<color>", inherits: true, value: "#fff" },
];
const addBrand: PantokenPlugin = {
  name: "brand",
  tokens: ({ tokens }) => [
    ...tokens,
    defineToken({ name: "--instui-brand", value: "#0374B5" }),
  ],
};

runTokenPlugins(base, "rebrand", [addBrand]); // → base + the --instui-brand token