pantoken / formats/css/src / toCss
Function: toCss()
toCss(
tokens,options?):string
Beta
Emit CSS for a token IR.
Parameters
tokens
readonly Token[]
The IR (e.g. from @pantoken/tokens).
options?
ToCssOptions = {}
Returns
string
The CSS string.
Examples
Build the default stylesheet
ts
import { toCss } from "@pantoken/css";
import { tokens } from "@pantoken/tokens";
const stylesheet = toCss(tokens); // declarations under :rootScope declarations to a class and build another theme
ts
import { toCss } from "@pantoken/css";
import { byTheme } from "@pantoken/tokens";
toCss(byTheme("canvas"), { scope: '[class*="instui"]' });Post-process with a plugin css hook
ts
import { toCss } from "@pantoken/css";
import { tokens } from "@pantoken/tokens";
toCss(tokens, {
plugins: [
{
name: "focus",
css: () => ({ append: ":focus-visible { outline: 2px solid var(--instui-focus-color); }" }),
},
],
});