Skip to content

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

Funkcija: toStyledTheme()

toStyledTheme(tokens, options?): StyledTheme

Eksperimentalno

Sestavi CSS-in-JS objekt teme iz token IR.

Parametri

tokens

readonly Token[]

IR (npr. iz @pantoken/tokens).

options?

ToStyledThemeOptions = {}

ToStyledThemeOptions.

Vrne

StyledTheme

Objekt teme, kjer so ključi imena tokenov v camelCase.

Primeri

Podprto z var(), svetli/temni tokovi prek @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)"

Ustvari konkretne enomodne vrednosti (za SSR brez CSS spremenljivk)

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