Skip to content

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

Функція: toStyledTheme() ​

toStyledTheme(tokens, options?): StyledTheme

Експериментальний

Побудувати об'єкт теми CSS-in-JS з IR токенів.

Параметри ​

tokens ​

тільки для читання Token[]

IR (наприклад, з @pantoken/tokens).

options? ​

ToStyledThemeOptions = {}

ToStyledThemeOptions.

Повертає ​

StyledTheme

Об'єкт теми, ключі — назви токенів у camelCase.

Приклади ​

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

Генерувати конкретні однорежимні значення (для SSR без 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()