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

شیٔ تم، با کلیدگذاری بر اساس نام توکن‌ها به صورت camelCased.

نمونه‌ها

پایه‌گرفته از 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()