Skip to content

pantoken / formats/css/src / toCss

Fungsi: toCss()

toCss(tokens, options?): string

Beta

Hasilkan CSS untuk IR token.

Parameter

tokens

hanya-baca Token[]

IR (mis. dari @pantoken/tokens).

options?

ToCssOptions = {}

ToCssOptions.

Mengembalikan

string

String CSS.

Contoh

Buat stylesheet default

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

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

Batasi deklarasi ke kelas dan buat tema lain

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

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

Lakukan pasca-proses dengan hook CSS 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); }" }),
    },
  ],
});