Skip to content

pantoken-root / formats/css/src / toCss

Funktion: toCss() ​

toCss(tokens, options?): string

Beta

Generera CSS för en token-IR.

Parametrar ​

tokens ​

skrivskyddad Token[]

IR:n (t.ex. från @pantoken/tokens).

options? ​

ToCssOptions = {}

ToCssOptions.

Returnerar ​

string

CSS‑strängen.

Exempel ​

Bygg standardstilarket

ts
import { toCss } from "@pantoken/css";
import { tokens } from "@pantoken/tokens";

const stylesheet = toCss(tokens); // declarations under :root

Begränsa deklarationer till en klass och bygg ett annat tema

ts
import { toCss } from "@pantoken/css";
import { byTheme } from "@pantoken/tokens";

toCss(byTheme("canvas"), { scope: '[class*="instui"]' });

Efterbearbeta med en 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); }" }),
    },
  ],
});