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