Color Picker
A component that allows users to select a color from a color palette or input a color value.
<script setup lang="ts">
import { ref } from 'vue'
import { parseColor, ColorPicker } from '@destyler-ui/vue'
const value = ref(parseColor('#eb5e41'))
</script>
<template>
<ColorPicker.Root v-model="value">
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger data-testid="trigger">
<ColorPicker.TransparencyGrid />
<ColorPicker.Context v-slot="colorPicker">
<ColorPicker.Swatch :value="colorPicker.value" data-testid="swatch-trigger" />
</ColorPicker.Context>
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner data-testid="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.ChannelSliderLabel>Alpha</ColorPicker.ChannelSliderLabel>
<ColorPicker.ChannelSliderValueText />
<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>
import { useState } from 'react'
import { ColorPicker, parseColor } from '@destyler-ui/react'
interface BasicProps {
defaultValue?: ReturnType<typeof parseColor>
lazyMount?: boolean
unmountOnExit?: boolean
}
export function Basic({ defaultValue, lazyMount, unmountOnExit }: BasicProps = {}) {
const [value, setValue] = useState(defaultValue ?? parseColor('#eb5e41'))
return (
<ColorPicker.Root
value={value}
onValueChange={details => setValue(details.value)}
lazyMount={lazyMount}
unmountOnExit={unmountOnExit}
>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger data-testid="trigger">
<ColorPicker.TransparencyGrid />
<ColorPicker.Context>
{colorPicker => (
<ColorPicker.Swatch value={colorPicker.value} data-testid="swatch-trigger" />
)}
</ColorPicker.Context>
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner data-testid="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.ChannelSliderLabel>Alpha</ColorPicker.ChannelSliderLabel>
<ColorPicker.ChannelSliderValueText />
<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 '@destyler-ui/solid/color-picker'
export function 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 module lang="ts">
import type { ColorPickerRootProps } from '@destyler-ui/svelte'
export interface BasicProps extends Omit<ColorPickerRootProps, 'value'> {}
</script>
<script lang="ts">
import { untrack } from 'svelte'
import { ColorPicker, parseColor } from '@destyler-ui/svelte'
const { defaultValue, ...props }: BasicProps = $props()
let value = $state(untrack(() => defaultValue ?? parseColor('#eb5e41')))
</script>
<ColorPicker.Root bind:value {...props}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger data-testid="trigger">
<ColorPicker.TransparencyGrid />
<ColorPicker.Context>
{#snippet render(colorPicker)}
<ColorPicker.Swatch value={colorPicker().value} data-testid="swatch-trigger" />
{/snippet}
</ColorPicker.Context>
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner data-testid="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.ChannelSliderLabel>Alpha</ColorPicker.ChannelSliderLabel>
<ColorPicker.ChannelSliderValueText />
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
{#each ['red', 'blue', 'green'] as swatch (swatch)}
<ColorPicker.SwatchTrigger value={swatch}>
<ColorPicker.Swatch value={swatch}>
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
{/each}
</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>
Anatomy
Section titled “Anatomy”<script setup lang="ts">import { ColorPicker } from '@destyler-ui/vue'</script>
<template> <ColorPicker.Root> <ColorPicker.Label /> <ColorPicker.Control> <ColorPicker.ChannelInput /> <ColorPicker.ValueText /> <ColorPicker.ValueSwatch /> <ColorPicker.Trigger /> </ColorPicker.Control> <ColorPicker.Positioner> <ColorPicker.Content> <ColorPicker.Area> <ColorPicker.AreaBackground /> <ColorPicker.AreaThumb /> </ColorPicker.Area> <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></template>import { ColorPicker } from '@destyler-ui/react'
export default function Basic() { return ( <ColorPicker.Root> <ColorPicker.Label /> <ColorPicker.Control> <ColorPicker.ChannelInput /> <ColorPicker.ValueText /> <ColorPicker.ValueSwatch /> <ColorPicker.Trigger /> </ColorPicker.Control> <ColorPicker.Positioner> <ColorPicker.Content> <ColorPicker.Area> <ColorPicker.AreaBackground /> <ColorPicker.AreaThumb /> </ColorPicker.Area> <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> )}import { ColorPicker, parseColor } from '@destyler-ui/solid'
export default function Basic() { return ( <ColorPicker.Root defaultValue={parseColor('#eb5e41')}> <ColorPicker.Label>Color</ColorPicker.Label> <ColorPicker.Control> <ColorPicker.ChannelInput channel="hex" /> <ColorPicker.ValueText /> <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.SwatchGroup> <ColorPicker.SwatchTrigger value="red"> <ColorPicker.Swatch value="red" /> </ColorPicker.SwatchTrigger> </ColorPicker.SwatchGroup> </ColorPicker.Content> </ColorPicker.Positioner> <ColorPicker.HiddenInput /> </ColorPicker.Root> )}<script lang="ts"> import { ColorPicker, parseColor } from '@destyler-ui/svelte'
let value = $state(parseColor('#eb5e41'))</script>
<ColorPicker.Root bind:value> <ColorPicker.Label>Color</ColorPicker.Label> <ColorPicker.Control> <ColorPicker.ChannelInput channel="hex" /> <ColorPicker.ChannelInput channel="alpha" /> <ColorPicker.ValueText /> <ColorPicker.Trigger> <ColorPicker.TransparencyGrid /> <ColorPicker.Context> {#snippet render(api)} <ColorPicker.Swatch value={api().value} /> {/snippet} </ColorPicker.Context> </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.SwatchGroup> {#each ['red', 'blue', 'green'] as swatch (swatch)} <ColorPicker.SwatchTrigger value={swatch}> <ColorPicker.Swatch value={swatch}> <ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator> </ColorPicker.Swatch> </ColorPicker.SwatchTrigger> {/each} </ColorPicker.SwatchGroup> </ColorPicker.Content> </ColorPicker.Positioner> <ColorPicker.HiddenInput /></ColorPicker.Root>Examples
Section titled “Examples”<script setup lang="ts">
import { ref } from 'vue'
import { parseColor, ColorPicker } from '@destyler-ui/vue'
const value = ref(parseColor('#eb5e41'))
</script>
<template>
<ColorPicker.Root v-model="value">
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger data-testid="trigger">
<ColorPicker.TransparencyGrid />
<ColorPicker.Context v-slot="colorPicker">
<ColorPicker.Swatch :value="colorPicker.value" data-testid="swatch-trigger" />
</ColorPicker.Context>
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner data-testid="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.ChannelSliderLabel>Alpha</ColorPicker.ChannelSliderLabel>
<ColorPicker.ChannelSliderValueText />
<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>
import { useState } from 'react'
import { ColorPicker, parseColor } from '@destyler-ui/react'
interface BasicProps {
defaultValue?: ReturnType<typeof parseColor>
lazyMount?: boolean
unmountOnExit?: boolean
}
export function Basic({ defaultValue, lazyMount, unmountOnExit }: BasicProps = {}) {
const [value, setValue] = useState(defaultValue ?? parseColor('#eb5e41'))
return (
<ColorPicker.Root
value={value}
onValueChange={details => setValue(details.value)}
lazyMount={lazyMount}
unmountOnExit={unmountOnExit}
>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger data-testid="trigger">
<ColorPicker.TransparencyGrid />
<ColorPicker.Context>
{colorPicker => (
<ColorPicker.Swatch value={colorPicker.value} data-testid="swatch-trigger" />
)}
</ColorPicker.Context>
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner data-testid="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.ChannelSliderLabel>Alpha</ColorPicker.ChannelSliderLabel>
<ColorPicker.ChannelSliderValueText />
<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 '@destyler-ui/solid/color-picker'
export function 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 module lang="ts">
import type { ColorPickerRootProps } from '@destyler-ui/svelte'
export interface BasicProps extends Omit<ColorPickerRootProps, 'value'> {}
</script>
<script lang="ts">
import { untrack } from 'svelte'
import { ColorPicker, parseColor } from '@destyler-ui/svelte'
const { defaultValue, ...props }: BasicProps = $props()
let value = $state(untrack(() => defaultValue ?? parseColor('#eb5e41')))
</script>
<ColorPicker.Root bind:value {...props}>
<ColorPicker.Label>Color</ColorPicker.Label>
<ColorPicker.Control>
<ColorPicker.ChannelInput channel="hex" />
<ColorPicker.ChannelInput channel="alpha" />
<ColorPicker.ValueText />
<ColorPicker.Trigger data-testid="trigger">
<ColorPicker.TransparencyGrid />
<ColorPicker.Context>
{#snippet render(colorPicker)}
<ColorPicker.Swatch value={colorPicker().value} data-testid="swatch-trigger" />
{/snippet}
</ColorPicker.Context>
</ColorPicker.Trigger>
</ColorPicker.Control>
<ColorPicker.Positioner data-testid="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.ChannelSliderLabel>Alpha</ColorPicker.ChannelSliderLabel>
<ColorPicker.ChannelSliderValueText />
<ColorPicker.TransparencyGrid />
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.SwatchGroup>
{#each ['red', 'blue', 'green'] as swatch (swatch)}
<ColorPicker.SwatchTrigger value={swatch}>
<ColorPicker.Swatch value={swatch}>
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
{/each}
</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
Section titled “Controlled”Control the selected color value programmatically.
<script setup lang="ts">
import { ColorPicker, parseColor } from '@destyler-ui/vue'
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>
import { useState } from 'react'
import { ColorPicker, parseColor } from '@destyler-ui/react'
export function Controlled() {
const [value, setValue] = useState(parseColor('hsl(20, 100%, 50%)'))
return (
<ColorPicker.Root format="hsla" value={value} onValueChange={details => setValue(details.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 '@destyler-ui/solid/color-picker'
import { createSignal } from 'solid-js'
export function Controlled() {
const [color, setColor] = createSignal(parseColor('hsl(0, 100%, 50%)'))
return (
<ColorPicker.Root
value={color()}
onValueChange={e => setColor(e.value)}
onValueChangeEnd={e => console.warn(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 lang="ts">
import { ColorPicker, parseColor } from '@destyler-ui/svelte'
let value = $state(parseColor('hsl(20, 100%, 50%)'))
</script>
<ColorPicker.Root format="hsla" bind: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>
{#each ['red', 'blue', 'green'] as swatch (swatch)}
<ColorPicker.SwatchTrigger value={swatch}>
<ColorPicker.Swatch value={swatch}>
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
{/each}
</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>
With Field
Section titled “With Field”Combine color picker with a form field for validation and labeling.
<script setup lang="ts">
import { parseColor, ColorPicker } from '@destyler-ui/vue'
import { Field } from '@destyler-ui/vue'
const defaultValue = parseColor('hsl(20, 100%, 50%)')
</script>
<template>
<Field.Root>
<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>
import { Field } from '@destyler-ui/react'
import { ColorPicker, parseColor } from '@destyler-ui/react'
interface WithFieldProps {
required?: boolean
disabled?: boolean
readOnly?: boolean
invalid?: boolean
}
export function WithField({ required, disabled, readOnly, invalid }: WithFieldProps = {}) {
return (
<Field.Root invalid={invalid}>
<ColorPicker.Root defaultValue={parseColor('hsl(20, 100%, 50%)')} disabled={disabled} readOnly={readOnly}>
<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 required={required} />
</ColorPicker.Root>
<Field.HelperText>Additional Info</Field.HelperText>
<Field.ErrorText>Error Info</Field.ErrorText>
</Field.Root>
)
}
import { ColorPicker, parseColor } from '@destyler-ui/solid/color-picker'
import { Field } from '@destyler-ui/solid/field'
export function WithField(props: Field.RootProps) {
return (
<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 module lang="ts">
export interface WithFieldProps {
required?: boolean
disabled?: boolean
readOnly?: boolean
invalid?: boolean
}
</script>
<script lang="ts">
import { Field } from '@destyler-ui/svelte'
import { ColorPicker, parseColor } from '@destyler-ui/svelte'
const { required, disabled, readOnly, invalid }: WithFieldProps = $props()
const defaultValue = parseColor('hsl(20, 100%, 50%)')
</script>
<Field.Root {invalid}>
<ColorPicker.Root {defaultValue} {disabled} {readOnly}>
<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 {required} />
</ColorPicker.Root>
<Field.HelperText>Additional Info</Field.HelperText>
<Field.ErrorText>Error Info</Field.ErrorText>
</Field.Root>
Root Provider
Section titled “Root Provider”<script setup lang="ts">
import { ColorPicker, useColorPicker } from '@destyler-ui/vue'
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>
import { ColorPicker, useColorPicker } from '@destyler-ui/react'
export function RootProvider() {
const colorPicker = useColorPicker()
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 '@destyler-ui/solid/color-picker'
export function 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 lang="ts">
import { ColorPicker, useColorPicker } from '@destyler-ui/svelte'
const id = $props.id()
const colorPicker = useColorPicker({ id })
</script>
<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>
{#each ['red', 'blue', 'green'] as swatch (swatch)}
<ColorPicker.SwatchTrigger value={swatch}>
<ColorPicker.Swatch value={swatch}>
<ColorPicker.SwatchIndicator>✓</ColorPicker.SwatchIndicator>
</ColorPicker.Swatch>
</ColorPicker.SwatchTrigger>
{/each}
</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>
API Reference
Section titled “API Reference”Root
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
closeOnSelect | false | false | trueWhether to close the color picker when a swatch is selected |
defaultOpen | — | false | trueThe initial open state of the color picker. |
defaultValue | — | colorPicker.ColorThe initial value of the color picker when it is first rendered. Use when you do not need to control the state of the color picker. |
disabled | — | false | trueWhether the color picker is disabled |
format | "rgba" | "rgba" | "hsla" | "hsba"The 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: colorPicker.ColorChannel) => string; channelSliderThumb: (id: colorPicker.ColorChannel) => string; }>The ids of the elements in the color picker. Useful for composition. |
initialFocusEl | — | () => HTMLElement | nullThe initial focus element when the color picker is opened. |
invalid | — | false | trueWhether the color picker is invalid |
lazyMount | false | false | trueWhether to enable lazy mounting |
modelValue | — | colorPicker.ColorThe v-model value of the color picker |
name | — | stringThe name for the form input |
open | — | false | trueWhether the color picker is open |
openAutoFocus | true | false | trueWhether to auto focus the color picker when it is opened |
positioning | — | calendar.PositioningOptionsThe positioning options for the color picker |
readOnly | — | false | trueWhether the color picker is read-only |
required | — | false | trueWhether the color picker is required |
unmountOnExit | false | false | trueWhether to unmount on exit. |
| Emit | Event |
|---|---|
focusOutside | [event: FocusOutsideEvent]Function called when the focus is moved outside the component |
formatChange | [details: FormatChangeDetails]Function called when the color format changes |
interactOutside | [event: InteractOutsideEvent]Function called when an interaction happens outside the component |
openChange | [details: OpenChangeDetails]Handler that is called when the user opens or closes the color picker. |
pointerDownOutside | [event: PointerDownOutsideEvent]Function called when the pointer is pressed down outside the component |
update:modelValue | [value: Color]The callback fired when the model value changes. |
update:open | [open: boolean] |
valueChange | [details: ValueChangeDetails]Handler that is called when the value changes, as the user drags. |
valueChangeEnd | [details: ValueChangeDetails]Handler that is called when the user stops dragging. |
Area
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
xChannel | — | "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha" |
yChannel | — | "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha" |
AreaBackground
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
AreaThumb
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelInput
| Prop | Default | Type |
|---|---|---|
channel* | — | ExtendedColorChannel |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
orientation | — | "horizontal" | "vertical" |
ChannelSlider
| Prop | Default | Type |
|---|---|---|
channel* | — | ColorChannel |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
orientation | — | "horizontal" | "vertical" |
ChannelSliderLabel
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderThumb
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderTrack
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderValueText
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Content
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
lazyMount | false | false | trueWhether to enable lazy mounting |
present | — | false | trueWhether the node is present (controlled by the user) |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Context
No serializable props or emits are declared for this part.
Control
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
EyeDropperTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
FormatSelect
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
FormatTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
HiddenInput
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Label
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
RootProvider
| Prop | Default | Type |
|---|---|---|
value* | — | MachineApi<PropTypes> |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
lazyMount | false | false | trueWhether to enable lazy mounting |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Swatch
| Prop | Default | Type |
|---|---|---|
value* | — | string | ColorThe color value |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
respectAlpha | — | false | trueWhether to include the alpha channel in the color |
SwatchGroup
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
SwatchIndicator
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
SwatchTrigger
| Prop | Default | Type |
|---|---|---|
value* | — | string | ColorThe color value |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
disabled | — | false | trueWhether the swatch trigger is disabled |
TransparencyGrid
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
size | — | string |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ValueSwatch
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
respectAlpha | — | false | trueWhether to include the alpha channel in the color |
ValueText
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
View
| Prop | Default | Type |
|---|---|---|
format* | — | ColorFormat |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Root
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
closeOnSelect | false | false | trueWhether to close the color picker when a swatch is selected |
defaultOpen | — | false | trueThe initial open state of the color picker when it is first rendered. Use when you do not need to control its open state. |
defaultValue | — | colorPicker.ColorThe initial value of the color picker when it is first rendered. Use when you do not need to control the state of the color picker. |
disabled | — | false | trueWhether the color picker is disabled |
format | "rgba" | "rgba" | "hsla" | "hsba"The 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: colorPicker.ColorChannel) => string; channelSliderThumb: (id: colorPicker.ColorChannel) => string; }>The ids of the elements in the color picker. Useful for composition. |
immediate | — | false | trueWhether 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. |
invalid | — | false | trueWhether the color picker is invalid |
lazyMount | false | false | trueWhether to enable lazy mounting |
name | — | stringThe name for the form input |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
onFocusOutside | — | (event: calendar.FocusOutsideEvent) => voidFunction called when the focus is moved outside the component |
onFormatChange | — | (details: colorPicker.FormatChangeDetails) => voidFunction called when the color format changes |
onInteractOutside | — | (event: calendar.InteractOutsideEvent) => voidFunction called when an interaction happens outside the component |
onOpenChange | — | (details: colorPicker.OpenChangeDetails) => voidHandler that is called when the user opens or closes the color picker. |
onPointerDownOutside | — | (event: calendar.PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component |
onValueChange | — | (details: colorPicker.ValueChangeDetails) => voidHandler that is called when the value changes, as the user drags. |
onValueChangeEnd | — | (details: colorPicker.ValueChangeDetails) => voidHandler that is called when the user stops dragging. |
open | — | false | trueWhether the color picker is open |
openAutoFocus | true | false | trueWhether to auto focus the color picker when it is opened |
positioning | — | calendar.PositioningOptionsThe positioning options for the color picker |
present | — | false | trueWhether the node is present (controlled by the user) |
readOnly | — | false | trueWhether the color picker is read-only |
required | — | false | trueWhether the color picker is required |
unmountOnExit | false | false | trueWhether to unmount on exit. |
value | #000000 | colorPicker.ColorThe current color value |
Area
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
xChannel | — | "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha" |
yChannel | — | "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha" |
AreaBackground
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
AreaThumb
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelInput
| Prop | Default | Type |
|---|---|---|
channel* | — | ExtendedColorChannel |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
orientation | — | "horizontal" | "vertical" |
ChannelSlider
| Prop | Default | Type |
|---|---|---|
channel* | — | ColorChannel |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
orientation | — | "horizontal" | "vertical" |
ChannelSliderLabel
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderThumb
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderTrack
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderValueText
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Content
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Context
| Prop | Default | Type |
|---|---|---|
children* | — | (context: UseColorPickerContext) => ReactNode |
Control
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
EyeDropperTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
FormatSelect
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
FormatTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
HiddenInput
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Label
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
RootProvider
| Prop | Default | Type |
|---|---|---|
value* | — | UseColorPickerReturn |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
lazyMount | false | false | trueWhether to enable lazy mounting |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
present | — | false | trueWhether the node is present (controlled by the user) |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Swatch
| Prop | Default | Type |
|---|---|---|
value* | — | string | ColorThe color value |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
respectAlpha | — | false | trueWhether to include the alpha channel in the color |
SwatchGroup
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
SwatchIndicator
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
SwatchTrigger
| Prop | Default | Type |
|---|---|---|
value* | — | string | ColorThe color value |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
disabled | — | false | trueWhether the swatch trigger is disabled |
TransparencyGrid
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
size | — | string |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
ValueSwatch
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
respectAlpha | — | false | trueWhether to include the alpha channel in the color |
ValueText
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
View
| Prop | Default | Type |
|---|---|---|
format* | — | ColorFormat |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Root
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
closeOnSelect | false | false | trueWhether to close the color picker when a swatch is selected |
defaultOpen | — | false | trueThe initial open state of the color picker when it is first rendered. Use when you do not need to control its open state. |
defaultValue | — | colorPicker.ColorThe initial value of the color picker when it is first rendered. Use when you do not need to control the state of the color picker. |
disabled | — | false | trueWhether the color picker is disabled |
format | "rgba" | "rgba" | "hsla" | "hsba"The color format to use |
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: colorPicker.ColorChannel) => string; channelSliderThumb: (id: colorPicker.ColorChannel) => string; }>The ids of the elements in the color picker. Useful for composition. |
immediate | — | false | trueWhether 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. |
invalid | — | false | trueWhether the color picker is invalid |
lazyMount | false | false | trueWhether to enable lazy mounting |
name | — | stringThe name for the form input |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
onFocusOutside | — | (event: colorPicker.FocusOutsideEvent) => voidFunction called when the focus is moved outside the component |
onFormatChange | — | (details: FormatChangeDetails) => voidFunction called when the color format changes |
onInteractOutside | — | (event: colorPicker.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: colorPicker.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 | — | false | trueWhether the color picker is open |
openAutoFocus | true | false | trueWhether to auto focus the color picker when it is opened |
positioning | — | colorPicker.PositioningOptionsThe positioning options for the color picker |
present | — | false | trueWhether the node is present (controlled by the user) |
readOnly | — | false | trueWhether the color picker is read-only |
required | — | false | trueWhether the color picker is required |
unmountOnExit | false | false | trueWhether to unmount on exit. |
value | #000000 | colorPicker.ColorThe current color value |
Area
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
xChannel | — | "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha" |
yChannel | — | "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha" |
AreaBackground
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
AreaThumb
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelInput
| Prop | Default | Type |
|---|---|---|
channel* | — | ExtendedColorChannel |
asChild | — | (props: (userProps?: solid_js424.JSX.InputHTMLAttributes<HTMLInputElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
orientation | — | "horizontal" | "vertical" |
ChannelSlider
| Prop | Default | Type |
|---|---|---|
channel* | — | ColorChannel |
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
orientation | — | "horizontal" | "vertical" |
ChannelSliderLabel
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.LabelHTMLAttributes<HTMLLabelElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderThumb
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderTrack
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
ChannelSliderValueText
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLSpanElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Content
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Context
| Prop | Default | Type |
|---|---|---|
children* | — | (context: UseColorPickerContext) => Element |
Control
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
EyeDropperTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.ButtonHTMLAttributes<HTMLButtonElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
FormatSelect
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.SelectHTMLAttributes<HTMLSelectElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
FormatTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.ButtonHTMLAttributes<HTMLButtonElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
HiddenInput
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.InputHTMLAttributes<HTMLInputElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Label
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.LabelHTMLAttributes<HTMLLabelElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
RootProvider
| Prop | Default | Type |
|---|---|---|
value* | — | UseColorPickerReturn |
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
lazyMount | false | false | trueWhether to enable lazy mounting |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
present | — | false | trueWhether the node is present (controlled by the user) |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Swatch
| Prop | Default | Type |
|---|---|---|
value* | — | string | ColorThe color value |
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
respectAlpha | — | false | trueWhether to include the alpha channel in the color |
SwatchGroup
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
SwatchIndicator
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
SwatchTrigger
| Prop | Default | Type |
|---|---|---|
value* | — | string | ColorThe color value |
asChild | — | (props: (userProps?: solid_js424.JSX.ButtonHTMLAttributes<HTMLButtonElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
disabled | — | false | trueWhether the swatch trigger is disabled |
TransparencyGrid
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
size | — | string |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.ButtonHTMLAttributes<HTMLButtonElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
ValueSwatch
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
respectAlpha | — | false | trueWhether to include the alpha channel in the color |
ValueText
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLSpanElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
View
| Prop | Default | Type |
|---|---|---|
format* | — | ColorFormat |
asChild | — | (props: (userProps?: solid_js424.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Root
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
closeOnSelect | false | false | trueWhether to close the color picker when a swatch is selected |
defaultOpen | — | false | true |
defaultValue | — | import("/home/runner/work/ui/ui/packages/svelte/dist/index").ColorPickerColor |
disabled | — | false | trueWhether the color picker is disabled |
format | "rgba" | "rgba" | "hsla" | "hsba"The color format to use |
id | — | string |
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 | — | false | trueWhether 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. |
invalid | — | false | trueWhether the color picker is invalid |
lazyMount | false | false | trueWhether to enable lazy mounting |
name | — | stringThe name for the form input |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
onFocusOutside | — | ((event: FocusOutsideEvent) => void) | undefinedFunction called when the focus is moved outside the component |
onFormatChange | — | (details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").ColorPickerFormatChangeDetails) => voidFunction called when the color format changes |
onInteractOutside | — | ((event: InteractOutsideEvent) => void) | undefinedFunction called when an interaction happens outside the component |
onOpenChange | — | (details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").ColorPickerOpenChangeDetails) => voidHandler that is called when the user opens or closes the color picker. |
onPointerDownOutside | — | ((event: PointerDownOutsideEvent) => void) | undefinedFunction called when the pointer is pressed down outside the component |
onValueChange | — | (details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").ColorPickerValueChangeDetails) => voidHandler that is called when the value changes, as the user drags. |
onValueChangeEnd | — | (details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").ColorPickerValueChangeDetails) => voidHandler that is called when the user stops dragging. |
open | — | false | trueWhether the color picker is open |
openAutoFocus | true | false | trueWhether to auto focus the color picker when it is opened |
positioning | — | PositioningOptions | undefinedThe positioning options for the color picker |
present | — | false | trueWhether the node is present (controlled by the user) |
readOnly | — | false | trueWhether the color picker is read-only |
required | — | false | trueWhether the color picker is required |
skipAnimationOnMount | false | false | trueWhether to allow the initial presence animation. |
unmountOnExit | false | false | trueWhether to unmount on exit. |
value | #000000 | import("/home/runner/work/ui/ui/packages/svelte/dist/index").ColorPickerColorThe current color value |
Area
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
xChannel | — | "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha" |
yChannel | — | "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha" |
AreaBackground
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
AreaThumb
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
ChannelInput
| Prop | Default | Type |
|---|---|---|
channel* | — | ExtendedColorChannel |
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"input">]> |
children | — | Snippet<[]> | undefined |
orientation | — | "horizontal" | "vertical" |
ChannelPropsProvider
No serializable props or emits are declared for this part.
ChannelSlider
| Prop | Default | Type |
|---|---|---|
channel* | — | ColorChannel |
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
orientation | — | "horizontal" | "vertical" |
ChannelSliderLabel
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"label">]> |
children | — | Snippet<[]> | undefined |
ChannelSliderThumb
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
ChannelSliderTrack
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
ChannelSliderValueText
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"span">]> |
children | — | Snippet<[]> | undefined |
Content
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
Context
| Prop | Default | Type |
|---|---|---|
render* | — | Snippet<[UseColorPickerContext]> |
Control
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
EyeDropperTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"button">]> |
children | — | Snippet<[]> | undefined |
FormatSelect
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"select">]> |
children | — | Snippet<[]> | undefined |
FormatTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"button">]> |
children | — | Snippet<[]> | undefined |
HiddenInput
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"input">]> |
children | — | Snippet<[]> | undefined |
Label
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"label">]> |
children | — | Snippet<[]> | undefined |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
Provider
No serializable props or emits are declared for this part.
RootProvider
| Prop | Default | Type |
|---|---|---|
value* | — | UseColorPickerReturn |
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
lazyMount | false | false | trueWhether to enable lazy mounting |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
present | — | false | trueWhether the node is present (controlled by the user) |
skipAnimationOnMount | false | false | trueWhether to allow the initial presence animation. |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Swatch
| Prop | Default | Type |
|---|---|---|
value* | — | string | ColorThe color value |
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
respectAlpha | — | false | trueWhether to include the alpha channel in the color |
SwatchGroup
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
SwatchIndicator
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
SwatchPropsProvider
No serializable props or emits are declared for this part.
SwatchTrigger
| Prop | Default | Type |
|---|---|---|
value* | — | string | ColorThe color value |
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"button">]> |
children | — | Snippet<[]> | undefined |
disabled | — | false | trueWhether the swatch trigger is disabled |
TransparencyGrid
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
size | — | string |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"button">]> |
children | — | Snippet<[]> | undefined |
ValueSwatch
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
respectAlpha | — | false | trueWhether to include the alpha channel in the color |
ValueText
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"span">]> |
children | — | Snippet<[]> | undefined |
format | — | "hex" | "css" | "rgba" | "hsla" | "hsba" | "hexa" | "rgb" | "hsl" | "hsb" |
View
| Prop | Default | Type |
|---|---|---|
format* | — | ColorFormat |
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |