Skip to the content
Konstruktor UI

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

  1. Copy templates/product-web/ to the product's repository. Its README says what to replace.
  2. Run its tools/kit-update.sh to copy the kit (ui/dist/kui-web/) into kit/. The kit's VERSION is written into the product's KIT_VERSION, so anyone can see which kit a product uses.
  3. Every page has <html lang="..." data-kui-theme="...">, the stylesheet kit/kui.css, the script kit/kui.js (with defer) and a skip link. Nothing loads from another site: fonts and icons are in the kit.
  4. Never edit files inside kit/. Extend with the product's own small stylesheet that uses only tokens.

2. Build pages from recipes and components

  1. 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.
  2. Use a component exactly as its page shows it. Copy the markup from the page's code block; keep its classes, roles and attributes.
  3. 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.
  4. 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-busy on the button.

4. Spacing, type and the one accent

  1. Use only tokens (--kui-*). No raw colour, length or duration in any stylesheet: ui/tools/check-tokens-only.mjs checks this for the kit; hold a product's CSS to the same rule.
  2. Space comes from the scale --kui-space-1 to --kui-space-10: gaps inside a component 1 to 4, between components 4 to 6, between sections --kui-space-section.
  3. Text: body 16 px on websites (--kui-text-lg), 14 px in dense application screens (--kui-text-md); headings with kui-h1 to kui-h5; long text in kui-prose at the measure. One heading level per step down.
  4. 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.
  5. Charts use the chart tokens in their fixed order; text in charts uses text tokens, never a series colour.

5. Writing interface text

  1. Plain, direct sentences. Say what a thing does: "Save changes", not "Submit". The verb comes first on a button.
  2. Errors say what to do: "Enter a date after today".
  3. Sentence case. No exclamation marks, no jokes in errors.
  4. 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.setWords changes them).
  5. Write numbers, dates and money with Intl in the page's language.

6. Accessibility (WCAG 2.2 AA, checked)

  1. Every control has a visible label; an icon-only button has an aria-label.
  2. Everything works with the keyboard alone, in a sensible order, with a visible focus ring. Never remove outlines.
  3. Touch targets are at least 44 by 44 px on phones. The kit's controls are; keep the product's own the same.
  4. 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.
  5. Respect prefers-reduced-motion (the kit does) and animate only feedback.
  6. Set lang on <html> and on any passage in another language.
  7. Pages work at 360 px wide with no sideways scroll, in light and dark.
  8. 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

  1. Write a seed: { "name": "harbour", "label": "Harbour", "accent": "#1f7a8c", "radius": "round", "density": "comfortable" } and, if wanted, "neutral": { "hue": 220, "chroma": 0.006 }.
  2. 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.
  3. Load theme.css after kit/kui.css, set data-kui-theme="harbour" on <html>, and list the themes a person may choose in <meta name="kui-themes" content="harbour gold">.
  4. Or use one of the ten shipped themes: gold, ocean, teal, forest, plum, rose, coral, slate, sand, ink.
  5. For Android, node ui/tools/kui-android.mjs --seed theme.json writes the same theme as Jetpack Compose sources (ui/android/kui-theme/).
  1. 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 DIR the 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 class kui-brand-NAME for 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".
  1. The public site of a business is built from the parts made for it: the first screen (kui-hero--site with 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

  1. Rebuild the kit (node ui/projects/konstruktor-ui/web/build.mjs), then run the product's tools/kit-update.sh. Commit kit/ and KIT_VERSION together.
  2. 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.