Skip to content

pantoken / formats/css/src / toCss

Swyddogaeth: toCss()

toCss(tokens, options?): string

Bêta

Allbwn CSS ar gyfer IR tocyn.

Paramedrau

tokens

darllen-yn-unig Token[]

Yr IR (er enghraifft o @pantoken/tokens).

options?

ToCssOptions = {}

ToCssOptions.

Yn dychwelyd

string

Y llinyn CSS.

Enghreifftiau

Adeiladu'r dalen arddull ddiofyn

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

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

Cyfyngu datganiadau i ddosbarth a chreu thema arall

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

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

Gorymdaith ôl-brosesu gyda hac CSS ategyn

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