<ColorSlider defaultValue="hsl(0, 100%, 50%)">
<Label>Hue</Label>
<ColorSliderControl />
</ColorSlider>Installation
npx shadcn@latest add @dotui/color-sliderUsage
Use color sliders to allow users to adjust an individual channel of a color value.
import { ColorSlider, ColorSliderControl } from '@/components/ui/color-slider'
import { Label } from '@/components/ui/field'<ColorSlider defaultValue="#ff0000" channel="hue">
<Label>Hue</Label>
<ColorSliderControl />
</ColorSlider>Anatomy
ColorSlider wraps a ColorSliderControl (the draggable track) and, optionally, a ColorSliderOutput (the current value as text) and a Label. If you render no children, ColorSlider falls back to a bare ColorSliderControl.
import {
ColorSlider,
ColorSliderControl,
ColorSliderOutput,
} from '@/components/ui/color-slider'
import { Label } from '@/components/ui/field'<ColorSlider>
<Label />
<ColorSliderOutput />
<ColorSliderControl />
</ColorSlider>Value
The value is a Color object. Use defaultValue for uncontrolled state — it accepts a color string like #f00 or hsl(0, 100%, 50%). For controlled state, pass value + onChange, where value is a parsed Color from parseColor and onChange receives a Color.
import { parseColor } from 'react-aria-components'
const [value, setValue] = React.useState(parseColor('hsl(0, 100%, 50%)'))
<ColorSlider value={value} onChange={setValue} channel="hue">
<ColorSliderControl />
</ColorSlider>Use channel to pick which channel the slider edits (hue, saturation, lightness, alpha…), and colorSpace (rgb, hsl, hsb) to interpret the value in a given space.
Examples
Default
With Opacity
API Reference
ColorSlider
A color slider allows users to adjust an individual channel of a color value.
| Prop | Type | Default | |
|---|---|---|---|
ColorChannel | — | ||
ReactNode | function | — | ||
ColorSpace | — | ||
boolean | — | ||
Orientation | 'horizontal' | ||
Color | string | — | ||
Color | string | — | ||
function | — | ||
function | — | ||
ColorSliderControl
A color slider control is the interactive track along which the thumb can be dragged.
| Prop | Type | Default | |
|---|---|---|---|
ReactNode | function | — | ||
ColorSliderOutput
A slider output displays the current value of a slider as text.
| Prop | Type | Default | |
|---|---|---|---|
ReactNode | function | — | ||
Last updated on 7/7/2026