Color wheel

<o-color-wheel> is a color picker: a hue ring around a saturation and brightness square, with optional swatches.

Drag around the ring for the hue, and inside the square for saturation (left to right) and brightness (bottom to top). The hue handle is the only satellite of an orbit-12 whose --o-from is the hue, so Orbit puts it on the ring; the ring and the square sit in center capsules. A gray keeps the hue you had, so turning the saturation back up brings it back.

Attributes

AttributeDefaultWhat it does
value#4fd1c5The color: hex, rgb(), hsl() or a CSS name. It is read as hex. It is also the default a form reset returns to; the attribute follows the picker as you change it.
formathexHow the color is submitted with a form: hex (#1e90ff), rgb (rgb(30, 144, 255)) or hsl (hsl(210, 100%, 56%)).
swatchesJSON: colors, or { color, label }. They go around the outside as satellites, and the picker shrinks to make room. Up to 36.
thickness1.9, 1.7 with swatchesHue ring thickness in lanes.
labelColor pickerAccessible name of the group, unless you give it an aria-label.
nameField name: with it, the picker submits its color with the form. See Forms.
disabledoffDimmed, out of the tab order and not submitted. A disabled <fieldset> does the same.
size240pxWidth of the widget.
themedark, light or glass. Also inherited from an ok-theme-* class on a container. See Shared options.

Properties and events

NameWhat it does
valueThe color as hex. Setting it takes any CSS color and fires no event, like a native input.
rgb, hslThe color as rgb() and hsl() text.
colorNameA plain name, like “dark blue” or “light gray”.
form, labels, defaultValue, validityAs on a native input.
inputFires on every change you make. event.detail has value (hex), rgb, hsl and name.
changeFires once a drag ends with a different color, on each key press and on each swatch you pick.
picker.addEventListener('input', (e) => preview(e.detail.value))
picker.value = 'tomato'
picker.value // '#ff6347'

Styling

PropertyDefaultWhat it does
--ok-cw-thumb-border#fffRing of the handles and of the picked swatch.
--ok-cw-swatch-borderfaint whiteEdge of the swatches, so dark ones show on a dark page.
--ok-cw-radius.3emCorner radius of the square.
--ok-focus#3da9fcFocus ring.
--ok-font-size8cqminBase size, as a share of the widget. The square's handle scales with it.

More examples

Swatches

A palette of your own around the picker. The swatch that matches the color is pressed.

In a form

With a name it submits like an input, here as hsl().

A light theme

Accessibility

The picker is a role="group" with two sliders, each one tab stop. The hue slider is called “Hue” and reads like “210 degrees, blue”; arrows move it one degree, Shift and Page Up or Page Down ten, Home and End go to the ends, and it wraps around. The square is called “Saturation and brightness”: Left and Right change the saturation, Up and Down the brightness, one percent at a time or ten with Shift. It reads like “Saturation 80%, brightness 60%, dark blue, #1f4c99”.

Swatches are buttons named after their label or their color, with aria-pressed on the one that matches. They share one tab stop; arrows move between them and Enter or Space picks one.