pickers
Color Picker
Pick a colour from a saturation and brightness area, a hue slider, a hex field or preset swatches, inline or inside a popover. Copy-paste ready.
Installation
Usage
Anatomy
Use any parts you need, in any order. For a compact field, put the picker in a Popover as in the example below.
Good to know
- Values are lowercase 6-digit hex strings, such as
"#3b82f6". The input also accepts 3-digit hex, with or without#. Alpha isn't supported. - The picker keeps its hue while you drag to grey, white or black, so dragging back brings the colour back.
- The area is keyboard accessible: focus its thumb, use the arrow keys to move 1%, and hold Shift to move 10%. The hue slider uses the usual slider keys.
- The hex field only applies a value once it's a complete colour, so half-typed text never jumps the picker. Enter applies 3-digit hex.
- Swatches show
aria-pressedwhen they match the current colour. hexToHsvandhsvToHexare exported if you need the conversions elsewhere, anduseColorPicker()gives custom parts access to the current colour.
API Reference
ColorPicker
ColorPickerSwatch
Examples
In a popover
Swatches only
Fixed label colours with a hex field for custom ones.