Skip to content

pantoken / packages/core/src / defineToken

Hàm: defineToken()

defineToken(input): Token

Beta

Xây dựng một Token hoàn chỉnh từ đầu vào một phần, mặc định inheritssyntax.

Tham số

input

TokenInput

Trả về

Token

Các ví dụ

Phát hiện cú pháp từ một giá trị cụ thể

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

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

Một giá trị var() duy nhất ghi refersTo; một light-dark() đặt 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