Skip to content

pantoken / renderers/react/src / useToken

函式: useToken()

useToken(name, fallback?): string

實驗性

React hook 回傳已解析的 --instui-* 代幣值(在 name 變更時重新讀取)。

參數

name

string

fallback?

string = ""

回傳

string

範例

tsx
import { useToken } from "@pantoken/react";

function Banner() {
  const brand = useToken("--instui-color-background-brand", "#0374B5");
  return <div style={{ background: brand }}>Saved</div>;
}