Color Picker

Choose a colour by hex, from a saturation square and hue slider, or with an eyedropper.

Default

A hex field with a swatch. Type a hex and press Enter, or open the swatch for a saturation square, a hue slider and an eyedropper.

Swatches

Preset colours under the picker, such as your palette tokens. The current colour is ringed.

Sizes

sm is 32px, for panels and toolbars. md is 36px, the same height as Input.

Secondary

A white field with a shadow, for neutral-50 and neutral-100 surfaces.

Best practices

When to use

  • Use when people set a brand or accent colour themselves: agent themes, widget colours, chart series.
  • Pass swatches when there is a palette to choose from; people then pick a sanctioned colour without leaving the field. Without a palette, keep the field and picker only.

Behavior

  • The swatch opens the picker; the hex field takes typing. A typed hex commits on Enter or blur, accepts 3 or 6 digits with or without #, and an invalid entry reverts.
  • onValueChange fires live while dragging the square or hue, always as uppercase #RRGGBB. Debounce saves if each change is expensive.
  • The eyedropper only appears where the browser supports it (Chromium). The hue is kept while the colour is grey, so dragging back up the square returns to it.
  • Use size="sm" (32px) in panels and toolbars and the default md (36px) in forms beside Input.

Content

  • Label the field with what the colour is for (“Brand color”, “Background”), not “Color”.

Accessibility

  • Pass aria-label; the swatch and both sliders take their names from it. The square moves with the arrow keys (Shift for bigger steps) and the hue with up and down.