Design guardrails
Check your QML application for accessibility, colour, layout,
typography, focus, motion, and content problems with ljos check
and ljos audit.
This page shows you how to check your QML code for design and accessibility defects using
ljos check and ljos audit, how to use the Ljos.Design token module so most issues never arise, and how to fix or waive a finding.Prose guidelines are easy to overlook, so Ljós turns its design rules into executable checks across four layers that all read from the same rule table (
ljos_design::RULES):1.
Design tokens (
Ljos.Design): A built-in QML module gives you colour roles grown from a single seed in OKLCH, motion durations and easing curves by frequency, a spacing scale that follows the theme's unit (4 px by default), and a type scale. ljos design export <dir> writes the same module out as plain QML files, so the tokens can also live in your repository.2.
Static lints (
ljos check and qml_lint): Static analysis inspects your QML source files for mistakes that are visible without running the app, such as ease-in on an entrance animation, scaling from zero, animating width or height, setting anchors on a direct child of a layout, dynamic text in a bounded box without elide or wrapMode, pointer-only actions, literal colours in components, or unnamed interactive items.3.
Runtime audit (
ljos audit and app_audit): The runtime audit lays out and draws the live scene across a test matrix—light and dark schemes, normal and high contrast, font scales up to 200 %, and narrow and short window sizes—and measures what was actually painted. It catches low contrast against composited backgrounds, clipped text, controls pushed outside the window or covered by overlays, missing keyboard focus rings, and popups that do not fit.4.
MCP design tools (
ljos mcp): Authoring tools (design_palette, design_contrast, design_motion, and design_rules) compute passing values before you write code.On Ljós,
import Ljos.Design is built in and requires no extra files in your project. Its colours follow the system colour scheme and contrast preference automatically:To keep the token module as plain QML files in your repository, export it:
Use the tools in order as you write and test a component:
When your application requires a running session or user interaction to reach a specific state, run it with the MCP inspector enabled or open the visual observer:
From an MCP client connected to
ljos run --mcp, call app_audit with {"matrix": "full"} (or {"matrix": "current"}, the default). The audit tests the live scene and restores the window state when it finishes. In Gherkin feature files, use the step the design audit finds nothing to assert that a scenario passes all checks.Severity reflects how certain the check is that a user is hurt:
If you intentionally keep code that triggers a Warning, add a
// ljos-allow(<code>): <reason> comment on the same line, the line above, or the first line of the enclosing QML object:Two rules keep allow comments honest:
lint-allow-without-reason (Error): Writing // ljos-allow(motion-duration) without a reason after the colon fails ljos check, because the next reader needs to know why the rule does not apply.lint-allow-unused (Hint): When a rule no longer triggers at that location, ljos check reports the stale allow comment so you can delete it.Every finding reports the rule code, the item's accessible role, name, and locator, the source file and line, what was measured against the limit (for example, a contrast ratio of
2.9:1 < 4.5:1), the matrix point where it failed, a suggested fix, and a link to the rule guide.Consider a component with three common issues: a literal grey text colour that fails contrast (
color-text-contrast and color-literal), an icon-only button without an accessible name or tooltip (a11y-unnamed-icon-button and a11y-icon-button-no-tooltip), and a dynamic label inside a bounded row with no elide mode (text-unbounded-dynamic):To fix these findings, bind surfaces and text to
palette roles (or Ljos.Design tokens), set elide and a conditional ToolTip on the bounded label (text-elided-hidden), and give the icon-only button text, display: AbstractButton.IconOnly, and a ToolTip that appears on hover and keyboard focus:Before you write a new component, answer eight questions:
1.
Frequency of use: Actions used many times a day (list selection, tab switch, shortcut) should be instant or take at most
limits::motion::FREQUENT_MAX_MS (100 ms). Rare panels or dialogs can take up to limits::motion::STANDARD_MAX_MS (350 ms).2.
Purpose of motion: Only animate to confirm input, show where an item came from or went, indicate a state change, or prevent a jarring jump.
3.
Colour weight (60-30-10): Use about 60 % tinted neutral surfaces, 30 % primary structural hue, and at most 10 % accent colour for the single primary call to action.
4.
All control states: Account for rest, hover, pressed, keyboard focus (
visualFocus), disabled (with a visible reason), checked/selected, loading, empty, and error states without relying on hue alone.5.
Keyboard path: Ensure Tab reaches every operable control in reading order, Enter or Space activates it, arrow keys move within composite groups, and Escape closes popups.
6.
Accessible names: Start every control's accessible name with its visible text, and give icon-only buttons
text, display: AbstractButton.IconOnly, and a tooltip.7.
Small windows and 200 % text: Decide beforehand what wraps, what elides (with a tooltip), and what scrolls so no control leaves the window.
8.
Dark mode and high contrast: Take every colour from a
palette role or Ljos.Design token rather than hex literals.






