Color Picker
A component that allows users to select a color from a color picker.
Anatomy
To set up the color picker correctly, you'll need to understand its anatomy and how we name its parts.
Each part includes a
data-partattribute to help identify them in the DOM.
Examples
Learn how to use the ColorPicker component in your project. Let's take a look at the most basic example
import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
export const Basic = () => {
return (
<ColorPicker.Root defaultValue={parseColor('#eb5e41')}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
)
}
import { ColorPicker, parseColor } from '@ark-ui/solid/color-picker'
export const Basic = () => {
return (
<ColorPicker.Root defaultValue={parseColor('#eb5e41')}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
)
}
<script setup lang="ts">
import { ColorPicker } from '@ark-ui/vue/color-picker'
</script>
<template>
<ColorPicker.Root>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
</template>
<script lang="ts">
import { ColorPicker, parseColor } from '@ark-ui/svelte/color-picker'
</script>
<ColorPicker.Root defaultValue={parseColor('#eb5e41')}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
Controlled
Use the value and onValueChange props to programatically control the color picker's state.
import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { useState } from 'react'
export const Controlled = () => {
const [color, setColor] = useState(() => parseColor('hsl(20, 100%, 50%)'))
return (
<ColorPicker.Root format="hsla" value={color} onValueChange={(e) => setColor(e.value)}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
)
}
import { ColorPicker, parseColor } from '@ark-ui/solid/color-picker'
import { createSignal } from 'solid-js'
export const Controlled = () => {
const [color, setColor] = createSignal(parseColor('hsl(0, 100%, 50%)'))
return (
<ColorPicker.Root
value={color()}
onValueChange={(e) => setColor(e.value)}
onValueChangeEnd={(e) => console.log(e.valueAsString)}
>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
)
}
<script setup lang="ts">
import { ColorPicker, parseColor } from '@ark-ui/vue/color-picker'
import { ref } from 'vue'
const value = ref(parseColor('hsl(20, 100%, 50%)'))
</script>
<template>
<ColorPicker.Root format="hsla" v-model="value">
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
</template>
<script lang="ts">
import { ColorPicker, parseColor } from '@ark-ui/svelte/color-picker'
let value = $state(parseColor('#eb5e41'))
</script>
<div>
<p>Selected color: {value.toString('hex')}</p>
<ColorPicker.Root bind:value>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
</div>
Alternatively, the
onValueChangeEndprop can be used to listen for when the user has finished selecting a color.
Field
The Field component helps manage form-related state and accessibility attributes of a color picker. It includes
handling ARIA labels, helper text, and error text to ensure proper accessibility.
import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { Field } from '@ark-ui/react/field'
export const WithField = (props: Field.RootProps) => (
<Field.Root {...props}>
<ColorPicker.Root defaultValue={parseColor('#eb5e41')}>
<ColorPicker.Label>Label</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content />
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
<Field.HelperText>Additional Info</Field.HelperText>
<Field.ErrorText>Error Info</Field.ErrorText>
</Field.Root>
)
import { ColorPicker, parseColor } from '@ark-ui/solid/color-picker'
import { Field } from '@ark-ui/solid/field'
export const WithField = (props: Field.RootProps) => (
<Field.Root {...props}>
<ColorPicker.Root defaultValue={parseColor('#eb5e41')}>
<ColorPicker.Label>Label</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content />
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
<Field.HelperText>Additional Info</Field.HelperText>
<Field.ErrorText>Error Info</Field.ErrorText>
</Field.Root>
)
<script setup lang="ts">
import { ColorPicker, parseColor } from '@ark-ui/vue/color-picker'
import { Field, type FieldRootProps } from '@ark-ui/vue/field'
const defaultValue = parseColor('hsl(20, 100%, 50%)')
const props = defineProps<FieldRootProps>()
</script>
<template>
<Field.Root v-bind="props">
<ColorPicker.Root :defaultValue>
<ColorPicker.Label>Label</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content />
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
<Field.HelperText>Additional Info</Field.HelperText>
<Field.ErrorText>Error Info</Field.ErrorText>
</Field.Root>
</template>
<script lang="ts">
import { ColorPicker, parseColor } from '@ark-ui/svelte/color-picker'
import { Field } from '@ark-ui/svelte/field'
</script>
<Field.Root>
<ColorPicker.Root defaultValue={parseColor('#eb5e41')}>
<ColorPicker.Label>Label</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content />
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.Root>
<Field.HelperText>Additional Info</Field.HelperText>
<Field.ErrorText>Error Info</Field.ErrorText>
</Field.Root>
Root Provider
Use the useColorPicker hook to create the color picker store and pass it to the ColorPicker.RootProvider component.
This allows you to have maximum control over the color picker programmatically.
import { ColorPicker, parseColor, useColorPicker } from '@ark-ui/react/color-picker'
export const RootProvider = () => {
const colorPicker = useColorPicker({ defaultValue: parseColor('#eb5e41') })
return (
<>
<span>Color: {colorPicker.valueAsString}</span>
<ColorPicker.RootProvider value={colorPicker}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.RootProvider>
</>
)
}
import { ColorPicker, parseColor, useColorPicker } from '@ark-ui/solid/color-picker'
export const RootProvider = () => {
const colorPicker = useColorPicker({ defaultValue: parseColor('#eb5e41') })
return (
<>
<span>Color: {colorPicker().valueAsString}</span>
<ColorPicker.RootProvider value={colorPicker}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.RootProvider>
</>
)
}
<script setup lang="ts">
import { ColorPicker, useColorPicker } from '@ark-ui/vue/color-picker'
const colorPicker = useColorPicker()
</script>
<template>
<span>Color: {{ colorPicker.valueAsString }}</span>
<ColorPicker.RootProvider :value="colorPicker">
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.TransparencyGrid />
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.RootProvider>
</template>
<script lang="ts">
import { ColorPicker, parseColor, useColorPicker } from '@ark-ui/svelte/color-picker'
const id = $props.id()
const colorPicker = useColorPicker({
id,
defaultValue: parseColor('#eb5e41'),
})
</script>
<div>
<p>External state: {colorPicker().valueAsString}</p>
<ColorPicker.RootProvider value={colorPicker}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ValueText />
<ColorPicker.Trigger>
<ColorPicker.ValueSwatch />
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner>
<ColorPicker.Content>
<ColorPicker.FormatTrigger>Toggle ColorFormat</ColorPicker.FormatTrigger>
<ColorPicker.FormatSelect />
<ColorPicker.Area>
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.ChannelSlider channel="alpha">
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
<ColorPicker.SwatchTrigger value="red">
<ColorPicker.Swatch value="red">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="blue">
<ColorPicker.Swatch value="blue">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
<ColorPicker.SwatchTrigger value="green">
<ColorPicker.Swatch value="green">
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
</ColorPicker.SwatchGroup>
<ColorPicker.View format="rgba">
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
</ColorPicker.View>
<ColorPicker.View format="hsla">
<ColorPicker.ChannelInput channel="hue" />
<ColorPicker.ChannelInput channel="saturation" />
<ColorPicker.ChannelInput channel="lightness" />
</ColorPicker.View>
<ColorPicker.EyeDropperTrigger>Pick color</ColorPicker.EyeDropperTrigger>
</ColorPicker.Content>
</ColorPicker.Positioner>
<ColorPicker.HiddenInput />
</ColorPicker.RootProvider>
</div>
If you're using the
ColorPicker.RootProvidercomponent, you don't need to use theColorPicker.Rootcomponent.
API Reference
Root
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. 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 | |
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 | |
lazyMount | false | booleanWhether to enable lazy mounting |
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 | |
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 | |
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 |
| CSS Variable | Description |
|---|---|
--value | The current value |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | root |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
[data-invalid] | Present when invalid |
AreaBackground
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | area-background |
[data-invalid] | Present when invalid |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
Area
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
xChannel | ColorChannel | |
yChannel | ColorChannel |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | area |
[data-invalid] | Present when invalid |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
AreaThumb
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| CSS Variable | Description |
|---|---|
--color | The text color |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | area-thumb |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
ChannelInput
| Prop | Default | Type |
|---|---|---|
channel | ExtendedColorChannel | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
orientation | Orientation |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | channel-input |
[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
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | channel-slider-label |
[data-channel] | The color channel of the channelsliderlabel |
ChannelSlider
| Prop | Default | Type |
|---|---|---|
channel | ColorChannel | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
orientation | Orientation |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | channel-slider |
[data-channel] | The color channel of the channelslider |
[data-orientation] | The orientation of the channelslider |
ChannelSliderThumb
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | channel-slider-thumb |
[data-channel] | The color channel of the channelsliderthumb |
[data-disabled] | Present when disabled |
[data-orientation] | The orientation of the channelsliderthumb |
ChannelSliderTrack
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | channel-slider-track |
[data-channel] | The color channel of the channelslidertrack |
[data-orientation] | The orientation of the channelslidertrack |
ChannelSliderValueText
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | channel-slider-value-text |
[data-channel] | The color channel of the channelslidervaluetext |
Content
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| CSS Variable | Description |
|---|---|
--layer-index | The index of the dismissable in the layer stack |
--nested-layer-count | The number of nested color-pickers |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | content |
[data-placement] | The placement of the content |
[data-nested] | popover |
[data-has-nested] | popover |
[data-state] | "open" | "closed" |
Control
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | control |
[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
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | eye-dropper-trigger |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
FormatSelect
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
FormatTrigger
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
HiddenInput
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Label
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | label |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
[data-invalid] | Present when invalid |
[data-focus] | Present when focused |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| CSS Variable | Description |
|---|---|
--transform-origin | The transform origin for animations |
--reference-width | The width of the reference element |
--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 |
--z-index | The z-index value |
--reference-height | The height of the root |
RootProvider
| Prop | Default | Type |
|---|---|---|
value | UseColorPickerReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
lazyMount | false | booleanWhether to enable lazy mounting |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
present | booleanWhether the node is present (controlled by the user) | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
SwatchGroup
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
SwatchIndicator
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
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. For more details, read our Composition guide. | |
respectAlpha | booleanWhether to include the alpha channel in the color |
| CSS Variable | Description |
|---|---|
--color | The text color |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | swatch |
[data-state] | "checked" | "unchecked" |
[data-value] | The value of the item |
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. For more details, read our Composition guide. | |
disabled | booleanWhether the swatch trigger is disabled |
| CSS Variable | Description |
|---|---|
--color | The text color |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | swatch-trigger |
[data-state] | "checked" | "unchecked" |
[data-value] | The value of the item |
[data-disabled] | Present when disabled |
TransparencyGrid
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
size | string |
| CSS Variable | Description |
|---|---|
--size | The size (width and height) of the element |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | trigger |
[data-disabled] | Present when disabled |
[data-readonly] | Present when read-only |
[data-invalid] | Present when invalid |
[data-placement] | The placement of the trigger |
[data-state] | "open" | "closed" |
[data-focus] | Present when focused |
ValueSwatch
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
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. For more details, read our Composition guide. | |
format | ColorStringFormat |
| Data Attribute | Value |
|---|---|
[data-scope] | color-picker |
[data-part] | value-text |
[data-disabled] | Present when disabled |
[data-focus] | Present when focused |
View
| Prop | Default | Type |
|---|---|---|
format | ColorFormat | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Accessibility
Keyboard Support
| Key | Description |
|---|---|
Enter | When focus is on the trigger, opens the color picker When focus is on a trigger of a swatch, selects the color (and closes the color picker) When focus is on the input or channel inputs, selects the color |
ArrowLeft | When focus is on the color area, decreases the hue value of the color When focus is on the channel sliders, decreases the value of the channel |
ArrowRight | When focus is on the color area, increases the hue value of the color When focus is on the channel sliders, increases the value of the channel |
ArrowUp | When focus is on the color area, increases the saturation value of the color When focus is on the channel sliders, increases the value of the channel |
ArrowDown | When focus is on the color area, decreases the saturation value of the color When focus is on the channel sliders, decreases the value of the channel |
Esc | Closes the color picker and moves focus to the trigger |