Color Picker
A component that allows users to select a color from a color picker.
Anatomy
<ColorPicker.Root>
<ColorPicker.Label />
<ColorPicker.Control>
<ColorPicker.ChannelInput />
<ColorPicker.Trigger>
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.EyeDropperTrigger />
<ColorPicker.ChannelSlider>
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger>
<ColorPicker.Swatch />
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
Examples
Controlled
Use value and onValueChange to control the color.
Open Controlled
Use open and onOpenChange to control the popover.
Root Provider
Use RootProvider with the useColorPicker hook to access the state and methods from outside the component.
Disabled
Set disabled to disable the color picker.
Inline
Set inline to render the picker without a popover.
Input Only
An input, value swatch and eye dropper trigger, with no popover content.
Slider Only
Only the RGB channel sliders.
Swatch Only
Only preset swatches.
Swatches
Add preset swatches to the content for quick selection.
Value Swatch
Show the current color as a swatch next to the area and sliders.
Field
Wrap the color picker in Field to wire up the label, helper text and error text accessibly.
Form Usage
Use HiddenInput to connect the color picker to form libraries like React Hook Form.
Inside Dialog
API Reference
Props
Root
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
closeOnSelect | false | booleanWhether to close the color picker when a swatch is selected |
defaultFormat | 'rgba' | ColorFormatThe initial color format when rendered. Use when you don't need to control the color format of the color picker. |
defaultOpen | booleanThe initial open state of the color picker when rendered. Use when you don't need to control the open state of the color picker. | |
defaultValue | #000000 | ColorThe initial color value when rendered. Use when you don't need to control the color value of the color picker. |
disabled | booleanWhether the color picker is disabled | |
format | ColorFormatThe controlled color format to use | |
hideMode | 'display-none' | HideModeHow to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+. |
id | stringThe unique identifier of the machine. | |
ids | ElementIdsThe ids of the elements in the color picker. Useful for composition. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
initialFocusEl | () => false | HTMLElement | nullThe initial focus element when the color picker is opened. Return `false` to skip moving focus, or `null` to use the default. | |
inline | booleanWhether to render the color picker inline | |
invalid | booleanWhether the color picker is invalid | |
lazyMount | false | booleanWhether to enable lazy mounting |
locale | 'en-US' | stringThe current locale. Based on the BCP 47 definition. |
name | stringThe name for the form input | |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
onFocusOutside | (event: FocusOutsideEvent) => voidFunction called when the focus is moved outside the component | |
onFormatChange | (details: FormatChangeDetails) => voidFunction called when the color format changes | |
onInteractOutside | (event: InteractOutsideEvent) => voidFunction called when an interaction happens outside the component | |
onOpenChange | (details: OpenChangeDetails) => voidHandler that is called when the user opens or closes the color picker. | |
onPointerDownOutside | (event: PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component | |
onValueChange | (details: ValueChangeDetails) => voidHandler that is called when the value changes, as the user drags. | |
onValueChangeEnd | (details: ValueChangeDetails) => voidHandler that is called when the user stops dragging. | |
open | booleanThe controlled open state of the color picker | |
openAutoFocus | true | booleanWhether to auto focus the color picker when it is opened |
positioning | PositioningOptionsThe positioning options for the color picker | |
present | booleanWhether the node is present (controlled by the user) | |
readOnly | booleanWhether the color picker is read-only | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ColorPickerRootState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
required | booleanWhether the color picker is required | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
value | ColorThe controlled color value of the color picker |
| Attribute | Description |
|---|---|
[data-color-picker-root] | <uid> |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
[data-invalid] | Present when invalid |
| CSS Variable | Description |
|---|---|
--value | The current value |
AreaBackground
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-area-background] | <uid> |
[data-invalid] | Present when invalid |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
Area
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
xChannel | ColorChannel | |
yChannel | ColorChannel |
| Attribute | Description |
|---|---|
[data-color-picker-area] | <uid> |
[data-invalid] | Present when invalid |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
AreaThumb
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-area-thumb] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
| CSS Variable | Description |
|---|---|
--color | The text color |
ChannelInput
Defines the <input> element.
| Attribute | Default | Type |
|---|---|---|
channel | ExtendedColorChannel | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
orientation | Orientation | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-channel-input] | <uid> |
[data-channel] | The color channel of the channelinput |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
ChannelSliderLabel
Defines the <label> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-channel-slider-label] | <uid> |
[data-channel] | The color channel of the channelsliderlabel |
ChannelSlider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
channel | ColorChannel | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
orientation | Orientation | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-channel-slider] | <uid> |
[data-channel] | The color channel of the channelslider |
[data-orientation] | The orientation of the channelslider |
ChannelSliderThumb
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-channel-slider-thumb] | <uid> |
[data-channel] | The color channel of the channelsliderthumb |
[data-disabled] | Present when disabled |
[data-orientation] | The orientation of the channelsliderthumb |
ChannelSliderTrack
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-channel-slider-track] | <uid> |
[data-channel] | The color channel of the channelslidertrack |
[data-orientation] | The orientation of the channelslidertrack |
ChannelSliderValueText
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-channel-slider-value-text] | <uid> |
[data-channel] | The color channel of the channelslidervaluetext |
Content
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ColorPickerContentState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-content] | <uid> |
[data-placement] | The placement of the content |
[data-side] | The side of the trigger that the content is positioned on |
[data-state] | "open" | "closed" |
[data-nested] | popover |
[data-has-nested] | popover |
| CSS Variable | Description |
|---|---|
--layer-index | The index of the dismissable in the layer stack |
--nested-layer-count | The number of nested color-pickers |
Control
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-control] | <uid> |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
[data-invalid] | Present when invalid |
[data-state] | "open" | "closed" |
[data-focus] | Present when focused |
EyeDropperTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-eye-dropper-trigger] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
FormatSelect
Defines the <select> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
FormatTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
HiddenInput
Defines the <input> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Label
Defines the <label> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-label] | <uid> |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
[data-invalid] | Present when invalid |
[data-required] | Present when required |
[data-focus] | Present when focused |
Positioner
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-positioner] | <uid> |
[data-nested] | Present when the positioner is nested within another {{widget}} |
[data-has-nested] | Present when the positioner has nested {{widget}}s |
| CSS Variable | Description |
|---|---|
--reference-width | The width of the reference element |
--reference-height | The height of the root |
--available-width | The available width in viewport |
--available-height | The available height in viewport |
--x | The x position for transform |
--y | The y position for transform |
--transform-origin | The transform origin for animations |
RootProvider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | UseColorPickerReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
hideMode | 'display-none' | HideModeHow to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+. |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
lazyMount | false | booleanWhether to enable lazy mounting |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
present | booleanWhether the node is present (controlled by the user) | |
render | type ONLY_FOR_FORMAT =
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ColorPickerRootProviderState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
SwatchGroup
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
SwatchIndicator
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Swatch
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | string | ColorThe color value | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
respectAlpha | booleanWhether to include the alpha channel in the color |
| Attribute | Description |
|---|---|
[data-color-picker-swatch] | <uid> |
[data-state] | "checked" | "unchecked" |
[data-value] | The value of the item |
| CSS Variable | Description |
|---|---|
--color | The text color |
SwatchTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
value | string | ColorThe color value | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
disabled | booleanWhether the swatch trigger is disabled | |
render | type ONLY_FOR_FORMAT =
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ColorPickerSwatchTriggerState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-swatch-trigger] | <uid> |
[data-state] | "checked" | "unchecked" |
[data-value] | The value of the item |
[data-disabled] | Present when disabled |
| CSS Variable | Description |
|---|---|
--color | The text color |
TransparencyGrid
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
size | string |
| CSS Variable | Description |
|---|---|
--size | The size (width and height) of the element |
Trigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ColorPickerTriggerState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-trigger] | <uid> |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
[data-invalid] | Present when invalid |
[data-placement] | The placement of the trigger |
[data-side] | The side of the trigger that the trigger is positioned on |
[data-state] | "open" | "closed" |
[data-focus] | Present when focused |
ValueSwatch
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
respectAlpha | booleanWhether to include the alpha channel in the color |
ValueText
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
format | ColorStringFormat | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-color-picker-value-text] | <uid> |
[data-disabled] | Present when disabled |
[data-focus] | Present when focused |
View
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
format | ColorFormat | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Context
API
| Property | Type |
|---|---|
dragging | booleanWhether the color picker is being dragged |
open | booleanWhether the color picker is open |
inline | booleanWhether the color picker is rendered inline |
value | ColorThe current color value (as a string) |
valueAsString | stringThe current color value (as a Color object) |
isInSrgbGamut | booleanWhether the current color lies inside the sRGB gamut (linear RGB cube). When `false`, wide-gamut CSS strings may still be valid while 8-bit RGB / hex are clamped. |
setValue | (value: string | Color) => voidFunction to set the color value |
getChannelValue | (channel: ColorChannel) => stringFunction to set the color value |
getChannelValueText | (channel: ColorChannel, locale?: string) => stringFunction to get the formatted and localized value of a specific channel. Uses the `locale` prop when `locale` is omitted. |
setChannelValue | (channel: ColorChannel, value: number) => voidFunction to set the color value of a specific channel |
format | ColorFormatThe current color format |
setFormat | (format: ColorFormat) => voidFunction to set the color format |
alpha | numberThe alpha value of the color |
setAlpha | (value: number) => voidFunction to set the color alpha |
setOpen | (open: boolean, reason?: OpenChangeReason) => voidFunction to open or close the color picker |
getRootState | () => RootStateReturns the state of the root |
getTriggerState | () => TriggerStateReturns the state of the trigger |
getContentState | () => ContentStateReturns the state of the content |
getGamutOverlay | (props?: GamutOverlayProps) => GamutOverlayData | nullSVG path + label position for the sRGB gamut boundary (oklch/oklab + HSB area only); `null` when not shown. Use the **same** `props` as |
getGamutOverlayProps | (props?: GamutOverlayProps) => T["svg"]Props for an `<svg>` gamut overlay; pair with |
Accessibility
Keyboard Support
| Key | Description |
|---|---|
Enter | When focus is on the trigger, opens the color picker When focus is on a swatch trigger, selects the color (and closes the color picker) When focus is on a channel input, commits the value |
ArrowLeftArrowRight | When focus is on the color area, decreases or increases the x channel When focus is on a channel slider, decreases or increases the channel |
ArrowUpArrowDown | When focus is on the color area, increases or decreases the y channel When focus is on a channel slider or a number channel input, increases or decreases the channel |
PageUpPageDown | When focus is on the color area, increases or decreases the y channel by a larger step When focus is on a channel slider, increases or decreases the channel by a larger step |
HomeEnd | When focus is on the color area, decreases or increases the x channel by a larger step When focus is on a channel slider, sets the channel to its minimum or maximum |
Esc | Closes the color picker and moves focus to the trigger |