---
title: "Color Slider"
description: "Change one channel of a color on a 12px gradient track: hue, saturation, lightness, brightness, red, green, blue, or alpha."
url: https://gelatinui.com/components/color-slider
markdown_url: https://gelatinui.com/components/color-slider.md
access: free
install: "npx shadcn@latest add @gelatin-ui/color-slider"
registry_item: https://gelatinui.com/r/color-slider.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Color Slider

> Change one channel of a color on a 12px gradient track: hue, saturation, lightness, brightness, red, green, blue, or alpha.

Page: https://gelatinui.com/components/color-slider

## When to use it

Best for: Change one channel of a color, such as hue or alpha, on a track that shows the channel gradient.

- Use it to change one channel of a color: hue, alpha, or red.
- Use `orientation="vertical"` for a tall panel.
- Put a `ColorSliderLabel` and a `ColorSliderOutput` in the children to show the name and the value.

## When not to use it

- To change two channels at once, use a [Color Area](https://gelatinui.com/components/color-area.md).
- For a value that is not a color, use a [Slider](https://gelatinui.com/components/slider.md).
- To type the exact number, use a [Color Field](https://gelatinui.com/components/color-field.md).

## Notes for agents

- Set `channel` to `hue`, `saturation`, `lightness`, `brightness`, `red`, `green`, `blue`, or `alpha`.
- `colorSpace` defaults to the space of the value.
- With no label, the name is the channel ("Hue"). Give a label or an `aria-label` for the purpose ("Fill opacity").
- One line renders the root, the track, and the thumb. Pass `track` to change a part.
- `onValueChange` runs during the drag. `onChangeEnd` runs on release.
- Inside a `ColorPicker`, it reads and sets the picker color with no props.

## Anatomy

```text
ColorSlider
├─ ColorSliderLabel (0..n)
├─ ColorSliderOutput (0..n)
├─ ColorSliderTrack (0..n)
└─ ColorSliderThumb (0..n)
```

## API reference

### ColorSlider

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string \| Color` |  | The current value (controlled). |
| `defaultValue` | `string \| Color` |  | The default value (uncontrolled). |
| `aria-label` | `string` |  | Defines a string value that labels the current element. |
| `aria-labelledby` | `string` |  | Identifies the element (or elements) that labels the current element. |
| `aria-describedby` | `string` |  | Identifies the element (or elements) that describes the object. |
| `aria-details` | `string` |  | Identifies the element (or elements) that provide a detailed, extended description for the object. |
| `id` | `string` |  | The element's unique identifier. See MDN. |
| `name` | `string` |  | The name of the input element, used when submitting an HTML form. See MDN. |
| `form` | `string` |  | The `<form>` element to associate the input with. The value of this attribute must be the id of a `<form>` in the same document. See MDN. |
| `dir` | `string` |  |  |
| `lang` | `string` |  |  |
| `hidden` | `boolean` |  |  |
| `inert` | `boolean` |  |  |
| `translate` | `"no" \| "yes"` |  |  |
| `suppressHydrationWarning` | `boolean` |  | A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs. |
| `onClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenu` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenuCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDown` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDownCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseEnter` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseLeave` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMove` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMoveCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOut` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOutCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOver` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOverCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUp` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUpCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancel` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancelCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEnd` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEndCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMove` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMoveCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStart` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStartCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onPointerDown` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerDownCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMove` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMoveCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUp` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUpCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancel` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancelCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerEnter` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerLeave` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOver` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOverCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOut` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOutCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onScroll` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onScrollCapture` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onWheel` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onWheelCapture` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStart` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStartCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEnd` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEndCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIteration` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIterationCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancel` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancelCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEnd` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEndCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRun` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRunCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStart` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStartCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `style` | `StyleOrFunction<ColorSliderRenderProps>` |  | The inline style for the element. A function may be provided to compute the style based on component state. |
| `children` | `ChildrenOrFunction` |  | The children of the component. A function may be provided to alter the children based on component state. |
| `slot` | `string \| null` |  | A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent. |
| `render` | `DOMRenderFunction` |  | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| `orientation` | `Orientation` | 'horizontal' | The orientation of the Slider. |
| `colorSpace` | `ColorSpace` |  | The color space that the slider operates in. The `channel` must be in this color space. If not provided, this defaults to the color space of the `color` or `defaultColor` value. |
| `channel` | `ColorChannel` |  | The color channel that the slider manipulates. |
| `onChangeEnd` | `function` |  | Handler that is called when the user stops dragging. |
| `disabled` | `boolean` |  | Turns off the control: no focus, no edits, and the disabled look. |
| `onValueChange` | `function` |  | Runs on each change, with the new value and the Base UI change details. |
| `className` | `string` |  |  |
| `track` | `ReactNode` |  | The track under the children. Default: a `ColorSliderTrack` with one `ColorSliderThumb`. Pass your own to change a part. |

### ColorSliderLabel

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `render` | `DOMRenderFunction<"label", undefined>` |  | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| `elementType` | `string` |  |  |
| `className` | `string` |  |  |

### ColorSliderOutput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `dir` | `string` |  |  |
| `lang` | `string` |  |  |
| `hidden` | `boolean` |  |  |
| `inert` | `boolean` |  |  |
| `translate` | `"no" \| "yes"` |  |  |
| `suppressHydrationWarning` | `boolean` |  | A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs. |
| `onClick` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onClickCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onAuxClick` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onAuxClickCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onContextMenu` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onContextMenuCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onDoubleClick` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onDoubleClickCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseDown` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseDownCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseEnter` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseLeave` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseMove` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseMoveCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseOut` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseOutCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseOver` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseOverCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseUp` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onMouseUpCapture` | `MouseEventHandler<HTMLOutputElement>` |  |  |
| `onTouchCancel` | `TouchEventHandler<HTMLOutputElement>` |  |  |
| `onTouchCancelCapture` | `TouchEventHandler<HTMLOutputElement>` |  |  |
| `onTouchEnd` | `TouchEventHandler<HTMLOutputElement>` |  |  |
| `onTouchEndCapture` | `TouchEventHandler<HTMLOutputElement>` |  |  |
| `onTouchMove` | `TouchEventHandler<HTMLOutputElement>` |  |  |
| `onTouchMoveCapture` | `TouchEventHandler<HTMLOutputElement>` |  |  |
| `onTouchStart` | `TouchEventHandler<HTMLOutputElement>` |  |  |
| `onTouchStartCapture` | `TouchEventHandler<HTMLOutputElement>` |  |  |
| `onPointerDown` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerDownCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerMove` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerMoveCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerUp` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerUpCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerCancel` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerCancelCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerEnter` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerLeave` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerOver` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerOverCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerOut` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onPointerOutCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onGotPointerCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onGotPointerCaptureCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onLostPointerCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onLostPointerCaptureCapture` | `PointerEventHandler<HTMLOutputElement>` |  |  |
| `onScroll` | `UIEventHandler<HTMLOutputElement>` |  |  |
| `onScrollCapture` | `UIEventHandler<HTMLOutputElement>` |  |  |
| `onWheel` | `WheelEventHandler<HTMLOutputElement>` |  |  |
| `onWheelCapture` | `WheelEventHandler<HTMLOutputElement>` |  |  |
| `onAnimationStart` | `AnimationEventHandler<HTMLOutputElement>` |  |  |
| `onAnimationStartCapture` | `AnimationEventHandler<HTMLOutputElement>` |  |  |
| `onAnimationEnd` | `AnimationEventHandler<HTMLOutputElement>` |  |  |
| `onAnimationEndCapture` | `AnimationEventHandler<HTMLOutputElement>` |  |  |
| `onAnimationIteration` | `AnimationEventHandler<HTMLOutputElement>` |  |  |
| `onAnimationIterationCapture` | `AnimationEventHandler<HTMLOutputElement>` |  |  |
| `onTransitionCancel` | `TransitionEventHandler` |  |  |
| `onTransitionCancelCapture` | `TransitionEventHandler` |  |  |
| `onTransitionEnd` | `TransitionEventHandler` |  |  |
| `onTransitionEndCapture` | `TransitionEventHandler` |  |  |
| `onTransitionRun` | `TransitionEventHandler` |  |  |
| `onTransitionRunCapture` | `TransitionEventHandler` |  |  |
| `onTransitionStart` | `TransitionEventHandler` |  |  |
| `onTransitionStartCapture` | `TransitionEventHandler` |  |  |
| `style` | `StyleOrFunction<SliderRenderProps>` |  | The inline style for the element. A function may be provided to compute the style based on component state. |
| `children` | `ChildrenOrFunction<SliderRenderProps>` |  | The children of the component. A function may be provided to alter the children based on component state. |
| `render` | `DOMRenderFunction` |  | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| `className` | `string` |  |  |

### ColorSliderTrack

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `dir` | `string` |  |  |
| `lang` | `string` |  |  |
| `hidden` | `boolean` |  |  |
| `inert` | `boolean` |  |  |
| `translate` | `"no" \| "yes"` |  |  |
| `suppressHydrationWarning` | `boolean` |  | A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs. |
| `onClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenu` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenuCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDown` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDownCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseEnter` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseLeave` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMove` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMoveCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOut` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOutCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOver` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOverCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUp` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUpCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancel` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancelCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEnd` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEndCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMove` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMoveCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStart` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStartCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onPointerDown` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerDownCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMove` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMoveCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUp` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUpCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancel` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancelCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerEnter` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerLeave` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOver` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOverCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOut` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOutCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onScroll` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onScrollCapture` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onWheel` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onWheelCapture` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStart` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStartCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEnd` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEndCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIteration` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIterationCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancel` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancelCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEnd` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEndCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRun` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRunCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStart` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStartCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onHoverStart` | `function` |  | Handler that is called when a hover interaction starts. |
| `onHoverEnd` | `function` |  | Handler that is called when a hover interaction ends. |
| `onHoverChange` | `function` |  | Handler that is called when the hover state changes. |
| `style` | `StyleOrFunction<SliderTrackRenderProps>` |  | The inline style for the element. A function may be provided to compute the style based on component state. |
| `children` | `ChildrenOrFunction` |  | The children of the component. A function may be provided to alter the children based on component state. |
| `render` | `DOMRenderFunction` |  | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| `className` | `string` |  |  |

### ColorSliderThumb

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `dir` | `string` |  |  |
| `lang` | `string` |  |  |
| `hidden` | `boolean` |  |  |
| `inert` | `boolean` |  |  |
| `translate` | `"no" \| "yes"` |  |  |
| `suppressHydrationWarning` | `boolean` |  | A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs. |
| `onClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenu` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenuCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDown` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDownCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseEnter` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseLeave` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMove` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMoveCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOut` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOutCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOver` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOverCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUp` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUpCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancel` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancelCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEnd` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEndCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMove` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMoveCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStart` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStartCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onPointerDown` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerDownCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMove` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMoveCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUp` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUpCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancel` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancelCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerEnter` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerLeave` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOver` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOverCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOut` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOutCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onScroll` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onScrollCapture` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onWheel` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onWheelCapture` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStart` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStartCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEnd` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEndCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIteration` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIterationCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancel` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancelCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEnd` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEndCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRun` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRunCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStart` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStartCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onHoverStart` | `function` |  | Handler that is called when a hover interaction starts. |
| `onHoverEnd` | `function` |  | Handler that is called when a hover interaction ends. |
| `onHoverChange` | `function` |  | Handler that is called when the hover state changes. |
| `style` | `StyleOrFunction<ColorThumbRenderProps>` |  | The inline style for the element. A function may be provided to compute the style based on component state. |
| `children` | `ChildrenOrFunction` |  | The children of the component. A function may be provided to alter the children based on component state. |
| `render` | `DOMRenderFunction` |  | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| `className` | `string` |  |  |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ColorSlider | `color-slider` | `data-disabled`, `data-orientation` |  |  |
| ColorSliderLabel | `color-slider-label` | `data-disabled` |  |  |
| ColorSliderOutput | `color-slider-output` |  |  |  |
| ColorSliderTrack | `color-slider-track` | `data-disabled`, `data-orientation` |  | `pattern` |
| ColorSliderThumb | `color-slider-thumb` |  |  |  |

## Usage

Set `channel` to the part of the color to change. Put a `ColorSliderLabel` and a `ColorSliderOutput` above the track.

```tsx title="layer-style.tsx"
import { ColorSlider, ColorSliderLabel, ColorSliderOutput } from "@/components/ui/color-slider";

export function LayerStyle() {
  return (
    <div className="flex w-64 flex-col gap-4">
      <ColorSlider channel="hue" defaultValue="hsla(211, 70%, 51%, 0.8)">
        <div className="flex items-center justify-between gap-2">
          <ColorSliderLabel>Hue</ColorSliderLabel>
          <ColorSliderOutput />
        </div>
      </ColorSlider>
      <ColorSlider channel="alpha" defaultValue="hsla(211, 70%, 51%, 0.8)">
        <div className="flex items-center justify-between gap-2">
          <ColorSliderLabel>Opacity</ColorSliderLabel>
          <ColorSliderOutput />
        </div>
      </ColorSlider>
    </div>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/color-slider
```

It adds 15 registry items: 10 files, 2120 lines, and the npm packages `@base-ui/react`, `clsx`, `react-aria-components`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Color Area](https://gelatinui.com/components/color-area.md)
- [Color Picker](https://gelatinui.com/components/color-picker.md)
- [Slider](https://gelatinui.com/components/slider.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Arrow keys | Moves the thumb one step. |
| Shift + arrow keys | Moves the thumb a large step. |
| Page Up, Page Down | Moves the thumb a large step. |
| Home, End | Moves the thumb to the start or the end. |

## Accessibility

It is a React Aria Color Slider. The thumb is a native range input, and the arrow keys change the value.

The press area of the track grows to 44px high for a finger.

React Aria reads the direction from `I18nProvider locale`.
