Skip to content

pantoken / formats/css/src / toCss

Fall: toCss()

toCss(tokens, options?): string

Beta

Senda út CSS fyrir tákn-IR.

Færibreytur

tokens

readonly Token[]

IR-ið (t.d. frá @pantoken/tokens).

options?

ToCssOptions = {}

ToCssOptions.

Skilar

string

CSS-strengurinn.

Dæmi

Byggja sjálfgefna stílblaðið

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

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

Afmarka yfirlýsingar við flokk og búa til annað þema

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

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

Eftirvinnsla með viðbótarkrók fyrir CSS

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