Skip to content

pantoken-root / formats/css/src / toCss

Fonksiyon: toCss() ​

toCss(tokens, options?): string

Beta

Token IR için CSS oluştur.

Parametreler ​

tokens ​

salt okunur Token[]

IR (ör. @pantoken/tokens'den).

options? ​

ToCssOptions = {}

ToCssOptions.

Döndürür ​

string

CSS dizesi.

Örnekler ​

Varsayılan stil sayfasını oluştur

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

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

Deklarasyonları bir sınıfa sınırla ve başka bir tema oluştur

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

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

Bir eklenti CSS kancasıyla son işlem uygula

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