Color Picker
Neon gel swatches, a hue knob and a hex field in one control.
nightjar
Records · Coffee · Open late
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/color-picker.jsonUsage
import { ColorPicker } from "@/components/ui/color-picker"
<ColorPicker label="Brand neon" defaultValue="#ff5fa2" onValueChange={(hex) => console.log(hex)} />Examples
Custom swatches
Pass your own gels with labels, and hide the hex field for a compact picker.
In a form
Give it a name and the hex submits with the form through a hidden input.
API reference
Also accepts native div attributes. The ref, className and style go to the panel.
| Prop | Type | Default |
|---|---|---|
value | stringControlled hex color, like "#22d3ee". Three-digit hex works too. | None |
defaultValue | stringInitial color when uncontrolled. | "#22d3ee" |
onValueChange | (hex: string) => voidCalled with a lowercase six-digit hex while dragging, and on every pick. | None |
swatches | (NeonColor | { value: NeonColor; label?: string })[]Gel presets as palette names or hex strings. Labels name them for screen readers and tooltips. | the neon palette |
showInput | booleanShow the hex field. | true |
eyeDropper | booleanOffer the screen color sampler. Only shown where the browser supports window.EyeDropper. | true |
label | ReactNodeVisible label above the panel. Names the group. | None |
name | stringSubmits the hex value with a surrounding form. | None |
disabled | booleanDims the panel and ignores input. | false |
size | "sm"Knob, strips, gels and field scale together. | "md" |
color | NeonColorAccent for focus rings and the hex field, not the picked color. | inherited |
containerClassName | stringClasses for the outer block with the label and panel. | None |
Accessibility
- With name, a form reset puts back the starting color.
- The hue knob and the saturation and lightness strips are each a role="slider". Arrow keys step by 1, Shift by 10, Home and End jump to the ends.
- Drag around the knob to point it at a hue, or scroll on it.
- Gels form a radio group with one tab stop. Arrow keys move through them and select as they go.
- The hex field applies six digits as you type and three on Enter or blur. Invalid input shows a message; Escape restores the current color.
- The preview tube is decorative and hidden from assistive tech; the value is in the hex field and the sliders.