Skip to content

pantoken / formats/css/src / toCss

Ֆունկցիա: toCss()

toCss(tokens, options?): string

Բետա

Արտադրել CSS՝ token IR‑ի համար.

Պարամետրեր

tokens

միայն կարդացվող Token[]

IR (օր. @pantoken/tokens-ից):

options?

ToCssOptions = {}

ToCssOptions.

Վերադարձվող արժեք

string

CSS տողը։

Օրինակներ

Կառուցել նախնական ոճաթերթը

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

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

Սահմանել հայտարարությունները դասի համար և կառուցել այլ թեմա

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

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

Պոստ-մշակում կատարել 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); }" }),
    },
  ],
});