Skip to content
Thrum

Color picker

A button that shows a colour and opens a picker with saturation/brightness, hue and opacity sliders, hex/RGB/HSL input, and swatches. Use ColorPickerPanel directly for sidebars or settings.

Install

npx shadcn@latest add @thrum-pro/color-picker

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Props

PropTypeDefaultDescription
valuestring–The colour as hex, when the parent holds it: #rrggbb, or #rrggbbaa when it is not fully opaque. Any format the field reads is accepted.
defaultValuestringDefault "#2563eb"The colour at first, when the picker holds it itself.
onValueChange(value: string) => void–Called with the new colour as lower-case hex while the reader drags, types or picks.
alphabooleanDefault falseAdd an opacity slider, and opacity in the field. Without it every colour is opaque.
swatchesreadonly string[]–Colours to pick with one press. The one that matches the colour is shown pressed.
defaultFormat"hex" | "rgb" | "hsl"Default "hex"The format the text field starts in. The reader can switch it.
disabledbooleanDefault falseDimmed, and nothing can be changed. The button does not open.
ColorPicker: aria-labelstringDefault "Colour"What the colour is for. It names the button, before the hex value, and the panel.
ColorPicker: namestring–The form field name. A hidden input carries the hex value.
ColorPicker: side"top" | "right" | "bottom" | "left"Default "bottom"The side of the button the panel opens on. It flips when there is no room.
ColorPicker: align"start" | "center" | "end"Default "start"How the panel lines up with the button.
ColorPicker: soundbooleanDefault truePlay the popover's soft sounds when it opens and closes and a click on swatch picks, if the visitor has sound on.
ColorPicker: triggerClassNamestring–Classes for the button.
ColorPickerPanel: surfacebooleanDefault truePaint the panel's own rounded border and glass surface. Set to false when embedded inside another panel.
classNamestring–ColorPickerPanel: classes for the panel, such as its width. It fills its container.

Motion and sound

Motion

  • The panel fades in and grows from 96% to full size over 150 ms, from the edge that touches the button, and plays it backwards to close.
  • Swatches scale subtly to 110% on hover and 95% on press over 150 ms. The marks follow the pointer and the keys with no easing, so they stay under the finger.
  • Reduced motion: the panel appears and leaves at once and swatches do not scale.

Sound

  • A soft rising tone when the panel opens, a falling one when it closes, and a soft click when a swatch is picked. Dragging and typing are silent.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • The area is hand-built on the WAI-ARIA slider pattern, in two dimensions: role slider named Saturation and brightness, with a value text that names the colour, such as dark blue, #1e3a8a, saturation 80%, brightness 54%.
  • Hue and opacity are Base UI sliders over native range inputs, named Hue and Opacity, with the hue's colour name in their value text.
  • The button is named by aria-label and the hex value, as in Brand colour: #2563eb. The panel is a non-modal dialog with the same name.
  • Swatches are toggle buttons named by colour and hex; the current one is pressed and outlined, not only coloured.
  • A colour typed in a format the field cannot read marks the field invalid and says what it expects.
  • Under a glass material the panel is translucent. Its tint keeps the text at 4.5 to 1 over any page; the colour ramps stay solid.
KeysAction
Enter / SpaceOn the button: open the panel. The focus moves to the area.
← / →Area: less or more saturation. Sliders: less or more hue or opacity.
↑ / ↓Area: brighter or darker. Sliders: more or less.
Shift + arrowMove 10 steps at a time.
Page Up / Page DownArea: 10 steps brighter or darker. Sliders: 10 steps.
Home / EndArea: no saturation or full saturation. Sliders: the lowest or highest value.
EnterIn the text field: apply the typed colour.
EscIn the text field with an edit: drop the edit. Otherwise close the panel; the focus returns to the button.

Source

SourcePro

The source comes with Pro

TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies

Files and dependencies

Adds
components/ui/color-picker.tsx
Packages
@base-ui/react@1.9.0
Brings along
ButtonInputNative selectPopoverSound engine

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor