Color Picker API
View componentThe full prop reference for the Color Picker component. An HSV color picker with hue and alpha sliders.
Import
import { ColorPicker } from '@structyl/styled';Props
Root
Main color picker container. Manages HSVA color state and provides context to child components. Can be controlled or uncontrolled.
| Prop | Type | Default |
|---|---|---|
| value# | HsvaColorControlled color value as HSVA object with h (0-360), s (0-1), v (0-1), a (0-1) channels | — |
| defaultValue# | HsvaColorInitial color value for uncontrolled component | { h: 0, s: 1, v: 1, a: 1 } |
| onValueChange# | (value: HsvaColor) => voidCallback fired when color value changes from any sub-component | — |
| disabled# | booleanDisables all child color picker interactions (passed to context, can be checked by child components) | — |
| asChild# | booleanRender as child element instead of div, merging props with child component | — |
| className# | stringCSS class name (styled version includes default: 'flex w-64 flex-col gap-3 p-3') | — |
| ref# | React.Ref<HTMLDivElement>Forwarded ref to the root div element | — |
Area
Interactive hue/saturation/value picker area. Displays a gradient from white/black to the current hue. Click/drag or use arrow keys to pick colors.
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name (styled version includes default: 'relative h-40 w-full rounded-md border border-border') | — |
| onPointerDown# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer down handler (composed with internal drag handler) | — |
| onPointerMove# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer move handler (composed with internal drag handler) | — |
| onPointerUp# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer up handler (composed with internal drag handler) | — |
| onKeyDown# | (event: React.KeyboardEvent<HTMLDivElement>) => voidKeyboard handler (composed with arrow key handlers for fine-tuning). Arrow keys adjust saturation/value; Shift+arrow adjusts by 0.1 instead of 0.01 | — |
| style# | React.CSSPropertiesInline styles (merged with internal gradient background) | — |
| ref# | React.Ref<HTMLDivElement>Forwarded ref to the area div element | — |
AreaThumb
Visual indicator (thumb/cursor) showing the currently selected position in the color area. Automatically positioned based on saturation and value.
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name (styled version includes default: 'h-3 w-3 rounded-full shadow-[0_0_0_2px_white,0_0_0_3px_rgba(0,0,0,0.4)]') | — |
| style# | React.CSSPropertiesInline styles (merged with internal absolute positioning) | — |
| ref# | React.Ref<HTMLSpanElement>Forwarded ref to the span element | — |
HueSlider
Styled convenience wrapper for selecting hue (0-360 degrees). Part of styled package only.
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name | 'relative h-3 w-full rounded-full' |
| onPointerDown# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer down handler (composed with internal drag handler) | — |
| onPointerMove# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer move handler (composed with internal drag handler) | — |
| onPointerUp# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer up handler (composed with internal drag handler) | — |
| style# | React.CSSPropertiesInline styles (merged with rainbow gradient background) | — |
| ref# | React.Ref<HTMLDivElement>Forwarded ref to the slider div element | — |
AlphaSlider
Styled convenience wrapper for selecting alpha/opacity (0-1). Part of styled package only.
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name | 'relative h-3 w-full rounded-full' |
| onPointerDown# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer down handler (composed with internal drag handler) | — |
| onPointerMove# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer move handler (composed with internal drag handler) | — |
| onPointerUp# | (event: React.PointerEvent<HTMLDivElement>) => voidPointer up handler (composed with internal drag handler) | — |
| style# | React.CSSPropertiesInline styles (merged with transparent-to-color gradient background) | — |
| ref# | React.Ref<HTMLDivElement>Forwarded ref to the slider div element | — |
Swatch
Color preview display showing the current color. Renders as a div with background color set to the hex equivalent of the current HSVA value with opacity.
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name (styled version includes default: 'h-8 w-8 rounded-md border border-border') | — |
| style# | React.CSSPropertiesInline styles (merged with background color and opacity computed from current value) | — |
| ref# | React.Ref<HTMLDivElement>Forwarded ref to the swatch div element | — |
Source code
If you didn't find what you need here, read the component implementation .