Skip to content

pantoken / renderers/css-in-js/src / toStyledTheme

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

toStyledTheme(tokens, options?): StyledTheme

Փորձարկումային

Տոկեն IR-ից կառուցել CSS-in-JS թեմայական օբյեկտ:

Պարամետրեր

tokens

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

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

options?

ToStyledThemeOptions = {}

ToStyledThemeOptions.

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

StyledTheme

Թեմայական օբյեկտ, camelCased տոկեն անունով բանալիացված:

Օրինակներ

var()-հետկացված, լույս/մութ հոսք @pantoken/css-ի միջոցով

ts
import { toStyledTheme } from "@pantoken/css-in-js";
import { tokens } from "@pantoken/tokens";

const theme = toStyledTheme(tokens);
// theme.colorBackgroundBrand → "var(--instui-color-background-brand)"

Գոյացնել կոնկրետ միայն-ռեժիմ արժեքներ (CSS փոփոխականներ անց SSR-ի համար)

ts
import { toStyledTheme } from "@pantoken/css-in-js";
import { tokens } from "@pantoken/tokens";

const dark = toStyledTheme(tokens, { resolve: "dark" });
// dark.colorBackgroundBase → a concrete value, not a var()