Kanok design
Kanok (กนก, after the flame-like Thai motif lai kanok) is the library's own style, next to Carbon. It is meant for internal business tools: clean and calm, surfaces set apart by their fill rather than lines, with a Thai-craft identity in its colours and one recurring detail. Every component keeps the same HTML, JavaScript and accessibility; only the stylesheet changes.
What it looks like
- Colour. Blue for actions (
#0068d6; dark: khram indigo#5563db), chad vermilion for danger, cool near-neutral greys on white (themepaper) and a violet-warm black (themelacquer). Every colour is generated and checked against WCAG 2.2 contrast when the package is built. - You are here. A blue line marks the selected tab, the current page in the header and a chosen table row (
--ui-border-interactive: the primary on paper, a lighter indigo on lacquer so it stays visible); in the side nav, a tree and vertical tabs the chosen row is tinted, with no bar. - No lines where a fill will do. Cards and tiles have no border: a soft grey sets them apart from the page, one step off whatever they sit on, in a layer too. Notifications and toasts have no coloured bar; the icon tells the kind.
- Focus. One light ring everywhere: solid blue (a light indigo on lacquer), 2px, with rounded corners, shown for the keyboard only. A click on a button, a checkbox or a toggle shows none; Tab does, 2px outside a control and inside a highlighted row. An input box (a text field, a dropdown, a select) shows its focus either way, as Pixiv's soft 4px blue halo outside the box, with no line on its edge; an invalid one has a red halo (Carbon: 2px, square, a click too).
- Shape. Pill-shaped buttons; 6px corners on fields, a soft grey fill with no edge (or an edge: see Outlined fields); 12px on cards, tiles and dialogs (a card's footer buttons sit 8px in) (a card clips its image to them); 8px on menus, notifications and code snippets. Tags have small 4px corners, so a status never reads as a button.
- No ink blocks. Secondary buttons are a soft grey fill with no border. Chosen things are the primary colour, never black: a selected tag, a chosen tile, the slider, the multi-select count.
- Density. Buttons and fields 40px tall by default (
sm32px,lg48px, as Carbon's fields), so a button lines up with the field beside it; menu rows 32px, table rows 40px. The large button sizes stay pills:xlis 48px and2xl56px, label centred (Carbon's 64 / 80px with the label at the top). - Select. A native select, as in Carbon: it opens the browser's own list, and a phone's own picker. For a list in the menu look, use a dropdown (or set
--ui-select-appearance: base-selectfor Chrome 135+'s customizable select). - Type. Bai Jamjuree for Thai and Latin, semibold labels and headings, and taller lines so stacked Thai vowels and tone marks never collide.
Use it
Load kanok.css after tokens.css (see Installation), then mark where Kanok applies:
data-design works on any element, not only <html>. An app that runs inside another product's frame (a portal with its own header and side bar) puts it on its own root element, so the host page is left alone:
React + Tailwind
The React + Tailwind components read the same settings, so they follow Kanok too. Copy kanok.css next to the tokens (npx shadcn@4 add @kanok-ui/kanok) and import it after them:
Then set data-design as above. In a micro app (React in a shadow root) put data-design and data-theme on the host element.
Outlined fields
Kanok's fields are filled by default: a soft grey fill, no edge. For fields with an edge, say a long form with many fields close together, or a form on a grey surface (a tile, a layer) where the soft fill is hard to see, use the outlined look.
To use it:
- Turn Kanok on as in Use it (
kanok.cssanddata-design="kanok"). - Put
data-field-variant="outlined"on an element around the fields: a<form>, a<section>, or<html>for the whole app. Every field inside follows; there's nothing to set per field and no component code to change. - It works the same for the web components, the React wrappers and React + Tailwind, since it's a plain HTML attribute.
Below, filled (left) and outlined (right) side by side:
The whole app outlined:
| State | filled (default) | outlined |
|---|---|---|
| Rest | soft grey fill, no edge | 1px edge, no fill |
| Focus | 4px blue halo | the same edge + 4px blue halo |
| Invalid | red halo | the same edge + red halo |
| Disabled | soft grey fill, faint text | faint edge, faint text |
The edge follows the theme (paper / lacquer) and is set by --ui-field-outline-color; a theme zone nested inside stays outlined. Keep one look per form.
Light and dark
Kanok has two themes: paper (light) and lacquer (dark). data-theme="auto" follows the system setting. You don't need to change anything for <ui-theme-switcher> or useThemeMode: on a Kanok page their light / dark choice becomes paper / lacquer. The core functions are in @purpurabog/ui/core:
| Function | Does |
|---|---|
applyDesign('kanok') |
sets data-design on <html> and moves the theme to the same mode in Kanok |
designScript() |
a <head> script that paints the remembered style (or ?design= from the URL) on the first frame; put it before themeScript() |
themeIn('kanok', 'g100') |
the theme a design shows for a mode: lacquer |
Adjust it
Kanok is a set of values for public CSS custom properties: colours (--ui-primary, --ui-border-interactive, …) and shape settings (--ui-button-radius, --ui-field-border, --ui-card-radius, --ui-menu-item-radius, …). Override any of them on a zone, as in Customizing. Each element's settings are listed in its API reference.
Status
Kanok is new. These components have their Kanok shape: button, the form fields (text input, text area, number, select, search, dropdown, combobox, multi-select, date and time pickers), checkbox, radio, toggle, tags, tabs, tiles, cards, tables (with a mark on a chosen row), menus, notifications, modals, button sets, code snippets, contained tabs (as a segmented control), the calendar, the header, the side nav, the content switcher, pagination, the slider, the file uploader, tooltips, popovers, toggletips, overflow menus, side panels and tearsheets. Every other component already takes Kanok's colours, font and sizes, and gets its shape in the next releases. The React + Tailwind components follow Kanok as well.