Skip to content

pantoken-root / formats/stylus/src / toStylus

Fonction: toStylus() ​

toStylus(tokens, options?): string

Expérimental

Génère des variables Stylus pour un IR de jetons.

Paramètres ​

tokens ​

lecture seule Token[]

L'IR (p. ex. provenant de @pantoken/tokens).

options? ​

ToStylusOptions = {}

ToStylusOptions.

Retourne ​

string

La chaîne source Stylus.

Exemples ​

Émettre les variables par défaut (thème clair)

ts
import { toStylus } from "@pantoken/stylus";
import { tokens } from "@pantoken/tokens";

toStylus(tokens); // "instui-color-brand = #0374b5\n…"

Résoudre le mode sombre d'un autre thème

ts
import { toStylus } from "@pantoken/stylus";
import { byTheme } from "@pantoken/tokens";

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