React
Usage
import { ColorPicker } from '@zalify-ui/react'
<ColorPicker.Root>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.Trigger>
<ColorPicker.Swatch value="#000000" />
</ColorPicker.Trigger>
</ColorPicker.Control>
</ColorPicker.Root>
Props
Root
| Prop | Default | Type |
|---|---|---|
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. |
defaultValue | #000000 | ColorThe initial color value when rendered. Use when you don't need to control the color value of the color picker. |
lazyMount | false | booleanWhether to enable lazy mounting |
openAutoFocus | true | booleanWhether to auto focus the color picker when it is opened |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
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. | |
disabled | booleanWhether the color picker is disabled | |
format | ColorFormatThe controlled color format to use | |
id | stringThe unique identifier of the machine. | |
ids | Partial<{ root: string; control: string; trigger: string; label: string; input: string; hiddenInput: string; content: string; area: string; areaGradient: string; positioner: string; formatSelect: string; areaThumb: string; channelInput: (id: string) => string; channelSliderTrack: (id: ColorChannel) => string; channe...The 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 | () => HTMLElement | nullThe initial focus element when the color picker is opened. | |
inline | booleanWhether to render the color picker inline | |
invalid | booleanWhether the color picker is invalid | |
name | stringThe name for the form input | |
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 | |
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 | |
required | booleanWhether the color picker is required | |
value | ColorThe controlled color value of the color picker |
Area
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
xChannel | ColorChannel | |
yChannel | ColorChannel |
ChannelInput
| Prop | Default | Type |
|---|---|---|
channel* | ExtendedColorChannel | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
orientation | Orientation |
ChannelSlider
| Prop | Default | Type |
|---|---|---|
channel* | ColorChannel | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
orientation | Orientation |
Swatch
| Prop | Default | Type |
|---|---|---|
value* | string | ColorThe color value | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
respectAlpha | booleanWhether to include the alpha channel in the color |
SwatchTrigger
| Prop | Default | Type |
|---|---|---|
value* | string | ColorThe color value | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
disabled | booleanWhether the swatch trigger is disabled |
TransparencyGrid
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
size | string |
ValueSwatch
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
respectAlpha | booleanWhether to include the alpha channel in the color |
ValueText
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
format | ColorStringFormat |
View
| Prop | Default | Type |
|---|---|---|
format* | ColorFormat | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. |