Skip to content

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

Fall: toStyledTheme() ​

toStyledTheme(tokens, options?): StyledTheme

Tilrauna

Byggja CSS-in-JS þemahlut úr token IR.

Færibreytur ​

tokens ​

aðeins til lestrar Token[]

IR-ið (t.d. frá @pantoken/tokens).

options? ​

ToStyledThemeOptions = {}

ToStyledThemeOptions.

Skilar ​

StyledTheme

Þemahluturinn, þar sem lyklar eru camelCased token nöfn.

Dæmi ​

var()-studd, ljós/dökk flæði gegnum @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)"

Innleiða fasta einstillta gildi (fyrir SSR án CSS-breytna)

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()