Skip to content

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