Building a product on Konstruktor UI
Read this before you build any Konstruktor product. It is short on purpose. Every rule here is checked by a script or shown on the reference site (ui/dist/kui-docs/, built by node ui/projects/konstruktor-ui/web/docs/build.mjs).
1. Start from the starter and the kit
- Copy
templates/product-web/to the product's repository. Its README says what to replace. - Run its
tools/kit-update.shto copy the kit (ui/dist/kui-web/) intokit/. The kit'sVERSIONis written into the product'sKIT_VERSION, so anyone can see which kit a product uses. - Every page has
<html lang="..." data-kui-theme="...">, the stylesheetkit/kui.css, the scriptkit/kui.js(withdefer) and a skip link. Nothing loads from another site: fonts and icons are in the kit. - Never edit files inside
kit/. Extend with the product's own small stylesheet that uses only tokens.
2. Build pages from recipes and components
- Find the closest recipe and copy its structure: landing, calculator, step-by-step guide, searchable directory, dashboard, form wizard, settings, login, article, phone app, business site.
- Use a component exactly as its page shows it. Copy the markup from the page's code block; keep its classes, roles and attributes.
- Use the layout primitives (
kui-container,kui-section,kui-stack,kui-cluster,kui-grid,kui-sidebar-layout,kui-split,kui-app) before writing any layout CSS. - Use native elements:
<button>for actions,<a href>for going somewhere,<input>,<select>,<details>,<dialog>. The custom elements only add behaviour to native markup, so pages still work without JavaScript wherever the task is not interactive by nature.
3. Which component for which job
- One value from a short list (2 to 5): segmented control. From a longer list: select. From a long list with typing: combobox. Several values: checkboxes, or multi-select when the list is long.
- On or off that acts at once: switch. On or off that is sent with a form: checkbox.
- A message about what just happened: toast. A state of the page or a form: alert. A note inside text: callout. Something for the whole site: banner. A decision that must be made now: dialog or
kui.confirm. - More content on demand: disclosure (one) or accordion (several). Extra information about one control: tooltip (a few words) or popover (more, or interactive).
- Sections of one screen: tabs. Steps of one task: stepper. Pages of a site: top bar and footer. Areas of an application: side navigation on a wide screen, bottom tab bar on a phone.
- A number that matters: stat tile, or the result card in a calculator. A trend: sparkline. Change over time: line chart. Parts of a whole: donut (up to five parts) or stacked bar.
- Nothing to show yet: empty state with the next action. Loading: skeleton for content, spinner for an action,
aria-busyon the button.
4. Spacing, type and the one accent
- Use only tokens (
--kui-*). No raw colour, length or duration in any stylesheet:ui/tools/check-tokens-only.mjschecks this for the kit; hold a product's CSS to the same rule. - Space comes from the scale
--kui-space-1to--kui-space-10: gaps inside a component 1 to 4, between components 4 to 6, between sections--kui-space-section. - Text: body 16 px on websites (
--kui-text-lg), 14 px in dense application screens (--kui-text-md); headings withkui-h1tokui-h5; long text inkui-proseat the measure. One heading level per step down. - The accent is for one thing per screen: the main action, the selection, focus and live state. Everything else is neutral. Status colours (ok, warn, danger, info) only show state, and always with an icon or a word.
- Charts use the chart tokens in their fixed order; text in charts uses text tokens, never a series colour.
5. Writing interface text
- Plain, direct sentences. Say what a thing does: "Save changes", not "Submit". The verb comes first on a button.
- Errors say what to do: "Enter a date after today".
- Sentence case. No exclamation marks, no jokes in errors.
- Every word the product shows is a key in its words files (one per language), read with the starter's
t(). The components' own words come from the kit (kui.setWordschanges them). - Write numbers, dates and money with
Intlin the page's language.
6. Accessibility (WCAG 2.2 AA, checked)
- Every control has a visible label; an icon-only button has an
aria-label. - Everything works with the keyboard alone, in a sensible order, with a visible focus ring. Never remove outlines.
- Touch targets are at least 44 by 44 px on phones. The kit's controls are; keep the product's own the same.
- Contrast: 4.5:1 for text, 3:1 for control outlines and focus. The theme generator guarantees this for the tokens; do not lay text on pictures or on chart colours.
- Respect
prefers-reduced-motion(the kit does) and animate only feedback. - Set
langon<html>and on any passage in another language. - Pages work at 360 px wide with no sideways scroll, in light and dark.
- Check the product's pages with
node ui/tools/web-checks/check-pages.mjs --root PRODUCT_DIR --pages index.html(list every page): no console errors, no other hosts, keyboard reach, names, axe, touch targets, in both modes at three sizes.
7. Make and check a product theme
- Write a seed:
{ "name": "harbour", "label": "Harbour", "accent": "#1f7a8c", "radius": "round", "density": "comfortable" }and, if wanted,"neutral": { "hue": 220, "chroma": 0.006 }. - Run
node ui/tools/kui-theme.mjs --seed theme.json --out theme.css. It derives every colour for light and dark and fails if any text or control pair is under AA. Change the seed until it passes; never edit the output. - Load
theme.cssafterkit/kui.css, setdata-kui-theme="harbour"on<html>, and list the themes a person may choose in<meta name="kui-themes" content="harbour gold">. - Or use one of the ten shipped themes: gold, ocean, teal, forest, plum, rose, coral, slate, sand, ink.
- For Android,
node ui/tools/kui-android.mjs --seed theme.jsonwrites the same theme as Jetpack Compose sources (ui/android/kui-theme/).
- A product theme can carry the product's own character. The kit is what a page is made of; the product's design direction decides how it is composed and how it looks. All of these are optional, the generator checks each one, and a seed without them looks as before:
"fonts": the display and body families from the font catalog (projects/konstruktor-ui/tokens/fonts.json: Inter, JetBrains Mono, Fraunces, Source Serif 4, Source Sans 3), the scripts the product writes in, and a fallback family for a script the first one lacks: `{ "display": "fraunces", "body": "source-sans-3", "scripts": ["latin", "latin-ext", "cyrillic"], "fallback": { "cyrillic": { "display": "source-serif-4" } } }`. A family the catalog lacks may be brought in"own"with its woff2 files, its licence file and its scripts. With--fonts-out DIRthe generator copies exactly the files the theme needs."brand": up to six named colours, `{ "deep": "#3b2416", "cream": "#faf6f0" }. Each becomes--kui-color-brand-NAME` with its text colour--kui-color-on-brand-NAME, in light and dark, and the classkui-brand-NAMEfor a band."headings"("text","accent"or a brand colour) and"labels"("accent"or a brand colour): the colour of headings and of the label over a heading, moved until it reads on every surface."page":"tint"(a tinted page with white bands, as the shipped themes) or"plain"(a white page with tinted bands), and"band": a brand colour for the band surface."button":"pill","rounded"or"square".
- The public site of a business is built from the parts made for it: the first screen (
kui-hero--sitewith a split of a ratio), the label (kui-eyebrow--brand), the large figure (kui-figure), the doors (kui-doors), bands (kui-band--tint,kui-band--brand), steps (kui-steps), line drawings (kui-drawing) and the call bar on a phone (kui-callbar). Start from the business site recipe; it carries a theme of its own (business-site.theme.json).
8. Updating the kit
- Rebuild the kit (
node ui/projects/konstruktor-ui/web/build.mjs), then run the product'stools/kit-update.sh. Commitkit/andKIT_VERSIONtogether. - If something in the kit is wrong or missing, fix it in the design system (
ui/projects/konstruktor-ui/web/), with its page and its check, not in the product.