Skip to content

pantoken / formats/css/src / toCss

Feidhm: toCss()

toCss(tokens, options?): string

Béite

Gineann CSS don token IR.

Paraiméadair

tokens

neamh-inathraitheach Token[]

An IR (m.sh. ó @pantoken/tokens).

options?

ToCssOptions = {}

ToCssOptions.

Tuairisceáin

string

An sreang CSS.

Samplaí

Tóg an stíleáil réamhshocraithe

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

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

Teorainn ráitis do rang agus tóg téama eile

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

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

Déan iarchóiriú le hook CSS breiseáin

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