Skip to content

pantoken-root / formats/css/src / toCss

Fonksyon: toCss() ​

toCss(tokens, options?): string

Beta

Jenere CSS pou yon IR token.

Paramèt ​

tokens ​

sèlman lekti Token[]

IR la (pa egzanp soti nan @pantoken/tokens).

options? ​

ToCssOptions = {}

ToCssOptions.

Retounen ​

string

Chèn CSS la.

Egzanp ​

Bati fich stil default la

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

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

Limite deklarasyon yo nan yon klas epi bati yon lòt tèm

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

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

Post-pwosesis ak yon hook CSS pou plugin

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