Skip to content

pantoken / plugin-kit

plugin-kit

Beta

@pantoken/plugin-kit — build and compose pantoken plugins, with capability-aware registration.

definePlugin is the modern factory: pass the hooks you implement and it returns a normal PantokenPlugin branded with the capabilities inferred from those hooks. Consumers (buildTokens, toCss) run checkPlugins to warn — never error — when a plugin is registered where it has no effect: a non-factoried plugin (capability checks unavailable) or a factoried plugin at a stage it doesn't implement (e.g. a token-only plugin passed to toCss).

The transform stages a plugins: array actually drives are tokens, icons, and css; rehype (a render-time icon resolver) and native (Style Dictionary) are recorded as capabilities but are downstream consumers, not guarded here.

Example

ts
const brand = definePlugin({ name: "brand", tokens: (c) => [...c.tokens], css: () => ({ ... }) });
// capabilitiesOf(brand) → ["tokens", "css"]

Interfaces

Type Aliases

Functions

References

Mode

Re-exports Mode