Skip to content

pantoken / renderers/mui/src / toMuiTheme

函数: toMuiTheme()

toMuiTheme(tokens, mode?): PantokenThemeOptions

实验性

从 token IR 构建 MUI 主题选项。

参数

tokens

只读 Token[]

IR(例如来自 @pantoken/tokens)。

mode?

Mode = "light"

要解析为哪种颜色模式(默认 "light")。

返回值

PantokenThemeOptions

为 MUI 的 createTheme 准备的选项。

示例

按品牌、按模式的主题

ts
import { createTheme } from "@mui/material/styles";
import { toMuiTheme } from "@pantoken/mui";
import { byTheme } from "@pantoken/tokens";

const darkCanvas = createTheme(toMuiTheme(byTheme("canvas"), "dark"));