Skip to content

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

פונקציה: toStyledTheme() ​

toStyledTheme(tokens, options?): StyledTheme

ניסיוני

בנה אובייקט תמה (theme) ב‑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()