Skip to content

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

関数: toStyledTheme()

toStyledTheme(tokens, options?): StyledTheme

実験的

トークンIRからCSS-in-JSのテーマオブジェクトを生成する。

パラメーター

tokens

読み取り専用 Token[]

IR(例: @pantoken/tokens からのもの)。

options?

ToStyledThemeOptions = {}

ToStyledThemeOptions.

戻り値

StyledTheme

テーマオブジェクト(キーはキャメルケース化されたトークン名)。

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

具体的なシングルモード値を固定化する(CSS変数なしのSSR向け)

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