Skip to content

pantoken-root / formats/less/src / toLess

Function: toLess() ​

toLess(tokens, options?): string

Experimental

Emit Less variables for a token IR.

Parameters ​

tokens ​

readonly Token[]

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

options? ​

ToLessOptions = {}

ToLessOptions.

Returns ​

string

The Less source string.

Examples ​

Emit the default (light) variables

ts
import { toLess } from "@pantoken/less";
import { tokens } from "@pantoken/tokens";

toLess(tokens); // "@instui-color-brand: #0374b5;\n…"

Resolve the dark mode of another theme

ts
import { toLess } from "@pantoken/less";
import { byTheme } from "@pantoken/tokens";

toLess(byTheme("canvas"), { mode: "dark" });