Installation
The package is public on npm. Pick the way that fits your app; you can mix them.
Choose a style
The components come in two styles. Both use the same JavaScript: a style is only a stylesheet.
| Style | Load | On the page |
|---|---|---|
| Carbon (the default) | tokens.css |
nothing to add |
| Kanok (our own design) | tokens.css, then kanok.css |
data-design="kanok" on <html> or on your app's root element |
| Both, switchable | the same two files | set or remove data-design at run time |
Kanok uses the Bai Jamjuree font (Thai and Latin, SIL Open Font License). Install it with npm i @fontsource/bai-jamjuree, then import the weights 400, 500, 600 and 700 (import '@fontsource/bai-jamjuree/400.css'; and so on).
To see the whole site in Kanok, open Settings (the gear in the header) and choose Kanok under Style, or share a link ending in ?design=kanok. More in Kanok design.
Web components (any framework)
Load the design tokens once per page, then the components you use:
React
React wrappers with typed props and events come with the package. They need @lit/react too (an optional peer dependency, only for @purpurabog/ui/react):
Load the tokens once (import '@purpurabog/ui/tokens.css';), then import the wrappers you use from @purpurabog/ui/react.
React + Tailwind with shadcn
Copy a component into your app and edit its classes. Its behaviour (keyboard, focus, ARIA) comes from @purpurabog/ui/headless, which the CLI installs for you.
- Your app needs Tailwind v4 and a
components.json. If you already use shadcn, add only theregistriespart:
Pin the version in the URL (@purpurabog/ui@0.82.0 instead of @latest) so every copy in your app comes from the same release.
- Add components:
- Import the tokens and the theme after Tailwind in your main CSS:
The files land in components/ui/ (under src/ when your app has one).
Unstyled React (headless)
For your own design system: the behaviour without a single class.
State shows as data-* attributes (data-open, data-selected, data-highlighted …) to style on. The parts have their own section: start at Headless.
Use your first component
The same dropdown as a web component, with the React wrapper and with React + Tailwind. Every example on this site comes in these tabs: pick yours once and the other pages follow. The headless version is in Headless.
lang on the element or any ancestor sets the language of the built-in text of the web components and the React wrappers (Thai and English are included).