structyl

Color Picker API

View component

The full prop reference for the Color Picker component. An HSV color picker with hue and alpha sliders.

Import

tsx
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.

PropTypeDefault
value#HsvaColor

Controlled color value as HSVA object with h (0-360), s (0-1), v (0-1), a (0-1) channels

defaultValue#HsvaColor

Initial color value for uncontrolled component

{ h: 0, s: 1, v: 1, a: 1 }
onValueChange#(value: HsvaColor) => void

Callback fired when color value changes from any sub-component

disabled#boolean

Disables all child color picker interactions (passed to context, can be checked by child components)

asChild#boolean

Render as child element instead of div, merging props with child component

className#string

CSS 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.

PropTypeDefault
className#string

CSS class name (styled version includes default: 'relative h-40 w-full rounded-md border border-border')

onPointerDown#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer down handler (composed with internal drag handler)

onPointerMove#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer move handler (composed with internal drag handler)

onPointerUp#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer up handler (composed with internal drag handler)

onKeyDown#(event: React.KeyboardEvent<HTMLDivElement>) => void

Keyboard 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.CSSProperties

Inline 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.

PropTypeDefault
className#string

CSS 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.CSSProperties

Inline 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.

PropTypeDefault
className#string

CSS class name

'relative h-3 w-full rounded-full'
onPointerDown#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer down handler (composed with internal drag handler)

onPointerMove#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer move handler (composed with internal drag handler)

onPointerUp#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer up handler (composed with internal drag handler)

style#React.CSSProperties

Inline 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.

PropTypeDefault
className#string

CSS class name

'relative h-3 w-full rounded-full'
onPointerDown#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer down handler (composed with internal drag handler)

onPointerMove#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer move handler (composed with internal drag handler)

onPointerUp#(event: React.PointerEvent<HTMLDivElement>) => void

Pointer up handler (composed with internal drag handler)

style#React.CSSProperties

Inline 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.

PropTypeDefault
className#string

CSS class name (styled version includes default: 'h-8 w-8 rounded-md border border-border')

style#React.CSSProperties

Inline 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 .

structyl — Accessible React Component Library