Skip to content

pantoken / formats/less/src / toLess

函数: toLess()

toLess(tokens, options?): string

实验性

为 token IR 生成 Less 变量。

参数

tokens

只读 Token[]

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

options?

ToLessOptions = {}

ToLessOptions.

返回值

string

Less 源字符串。

示例

输出默认(浅色)变量

ts
import { toLess } from "@pantoken/less";
import { tokens } from "@pantoken/tokens";

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

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

ts
import { toLess } from "@pantoken/less";
import { byTheme } from "@pantoken/tokens";

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