Shared options

Themes, number format, min, max and step, and forms work the same in every kit component that has them.

Themes

Put theme="dark", "light" or "glass" on a component, or the class ok-theme-dark, ok-theme-light or ok-theme-glass on a container. Everything inside follows, so one class themes a whole dashboard.

Turn a knob: the gauge next to it follows.
  • A theme is a set of the --ok-* custom properties, inside :where(). It has zero specificity, so any rule of yours wins, and color attributes like fill win too.
  • Custom properties inherit, so the closest theme wins: a theme="light" gauge inside an ok-theme-dark panel is light.
  • Without a theme, components keep their own defaults.
  • Glass makes faces and panels translucent and blurs what is behind them (backdrop-filter). It wants a colorful or photographic background.

The properties a theme sets, and what reads them:

PropertyWhat it colors
--ok-fill, --ok-trackValue arcs and their tracks.
--ok-accentNeedles, second hands, compass index, menu highlight.
--ok-textReadouts, numerals and labels.
--ok-face, --ok-bezel, --ok-caseDials, their rims and the case around them.
--ok-tick, --ok-handMinor ticks; hands, major ticks and strong numbers.
--ok-surfacePanels such as the menu hub and the needle cap.
--ok-focusFocus rings.
--ok-backdropThe backdrop-filter of faces and panels. Set by glass.

To tweak a theme, set a property next to it:

.dashboard { --ok-fill: #ffb547; }   /* beats the theme */
<div class="dashboard ok-theme-dark"> … </div>

The menu already had a theme attribute for its sector colors. That is now palette="mono|color"; theme="color" still works and combines with the others, as in theme="color light".

Number format

format picks how numbers are written, through Intl.NumberFormat. It reaches the readout, the tick labels and aria-valuetext.

Switch the format and the locale: the readout and the scale change together.
AttributeWhat it does
formatdecimal, percent, currency, unit or compact (1.2K, 3.4M).
decimalsDigits after the decimal point, fixed. Without it, each format uses its usual number.
currencyISO code for format="currency", USD by default. Setting it alone implies the currency format.
unitText after the number, as before (unit="%"). With format="unit" it names an Intl unit instead: kilometer-per-hour, celsius, megabyte.
localeA language tag like de-DE. Without it, the closest lang attribute, then the browser's language.

percent shows where the value sits between min and max: 50 on a 0 to 200 gauge reads 25%. In a donut it is the share of the total. Without any of these attributes, numbers look the way they did in 1.0. A bad currency or unit never breaks the component: it falls back to a plain number.

A formatter for full control

Set formatter to a function and it writes every number. The second argument says where the number goes: kind is value, tick or aria, and you get min, max and locale. Its text is used as is, without the unit.

min, max and step

Every component with a value reads min, max and step the way <input type="range"> does.

Drag, scroll or use the arrow keys: every value lands on a half step.
  • Values are clamped to the range, readouts included. A max below min becomes min.
  • step snaps values to a grid that starts at min. Both ends stay reachable, even when the step does not divide the range. step="any" turns snapping off.
  • Display components (gauge, meter, instrument) do not snap unless you give them a step. The knob steps by 1.
  • Keys: arrows move one step, Page Up and Page Down ten, Home and End go to the ends. Without a step they move 1% of the range.
  • aria-valuemin, aria-valuemax, aria-valuenow and aria-valuetext follow, the last one through the number format.

Rings read min and max as defaults for each ring, and a ring in data can set its own. The radar reads dist between them, so blips can be in kilometers. On the rings, step was already the space between rings; it keeps that meaning, and spacing is its new name.

Forms

<o-knob> and <o-menu> are form controls. Give them a name and they submit with their form like an <input>.

Order without a size and the browser points at the menu. Reset puts the knob back on 3.
NameWhat it does
nameThe field name in the form data. Without it, nothing is sent.
valueThe attribute is the default value: the control starts there and a form reset goes back to it. The property is the current value; setting it fires no event.
disabledOut of the tab order, ignores input and is not sent. A disabled <fieldset> does the same. :disabled works in CSS.
requiredMenu only: the form does not submit until an item is picked. A knob always has a value.
input, changeEvents, as on native inputs: input on every change by the user, change when a gesture ends, on each key press, and on each menu pick. event.detail.value has the value.
form, labels, validity, checkValidity(), reportValidity()The same as on an <input>. A <label for> names the control.

The menu submits the value of the picked item, as JSON when it is an object. Pages restored with the back button come back with the values they had.

Which component takes what

ComponentThemeFormatmin / max / stepForm
Gaugeyesreadoutall three
Knobyesreadoutall three, keysyes
Menuyesyes
Instrumentyesreadout, scaleall three
Donutyessegments
Ringsyesringsmin, max
Compassyesheading
Radaryesdistancesmin, max
Radar chartyestooltip, scale, tablemin, max, also per axis
Spinneryesprogress readoutmin, max
Sunburstyesvalues, middle
Rangeyesreadoutall three, keysyes
Time pickeryesmin, max (times)yes
Color wheelyesyes
Wheelyes
Clock, Timer, Statusyes

<o-meter> takes the same as the instrument. Clocks and timers show times, not numbers, so they have no number format.