Skip to content

pantoken / formats/css/src / toCss

Functie: toCss()

toCss(tokens, options?): string

Bèta

Genereer CSS voor een token IR.

Parameters

tokens

alleen-lezen Token[]

De IR (bijvoorbeeld van @pantoken/tokens).

options?

ToCssOptions = {}

ToCssOptions.

Retourneert

string

De CSS-string.

Voorbeelden

Bouw het standaardstijlblad

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

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

Beperk declaraties tot een klasse en bouw een ander thema

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

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

Nabewerken met een 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); }" }),
    },
  ],
});