Skip to content

pantoken / formats/scss/src / toScss

函数: toScss()

toScss(tokens, options?): string

实验性

为 token IR 生成 SCSS 变量。

参数

tokens

只读 Token[]

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

options?

ToScssOptions = {}

ToScssOptions.

返回值

string

SCSS 源字符串。

示例

输出默认(浅色)变量

ts
import { toScss } from "@pantoken/scss";
import { tokens } from "@pantoken/tokens";

toScss(tokens); // "$instui-color-brand: #0374b5;\n…"

解析另一个主题的暗色模式

ts
import { toScss } from "@pantoken/scss";
import { byTheme } from "@pantoken/tokens";

toScss(byTheme("canvas"), { mode: "dark" });