Skip to content

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

Funzione: toStyledTheme()

toStyledTheme(tokens, options?): StyledTheme

Sperimentale

Costruisci un oggetto tema CSS-in-JS da un IR di token.

Parametri

tokens

readonly Token[]

L'IR (es. da @pantoken/tokens).

options?

ToStyledThemeOptions = {}

ToStyledThemeOptions.

Restituisce

StyledTheme

L'oggetto tema, con chiavi basate sul nome del token in camelCase.

Esempi

Supportato da var(), flussi light/dark tramite @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)"

Includi valori concreti per modalità singola (per SSR senza variabili CSS)

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