Skip to content

pantoken-root / packages/core/src / defineToken

函式: defineToken() ​

defineToken(input): Token

Beta(測試)

從部分輸入建立完整的 Token,預設為 inherits 和 syntax。

參數 ​

input ​

TokenInput

回傳 ​

Token

範例 ​

從具體值推斷語法

ts
import { defineToken } from "@pantoken/core";

defineToken({ name: "--instui-color-x", value: "#0374B5" });
// → { name: "--instui-color-x", syntax: "<color>", inherits: true, value: "#0374B5" }

單一 var() 值會記錄 refersTo;light-dark() 會設定 themed

ts
import { defineToken } from "@pantoken/core";

defineToken({ name: "--instui-brand", value: "var(--instui-color-background-brand)" });
// → syntax "*", refersTo: "--instui-color-background-brand"

defineToken({ name: "--instui-bg", value: "light-dark(#fff, #000)" });
// → syntax "*", themed: true