---
title: "Slider"
description: "Pick a value or a range: drag a thumb along a thin track, or use the arrow keys. It has a label, a value, and one thumb for each value."
url: https://gelatinui.com/components/slider
markdown_url: https://gelatinui.com/components/slider.md
access: free
install: "npx shadcn@latest add @gelatin-ui/slider"
registry_item: https://gelatinui.com/r/slider.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Slider

> Pick a value or a range: drag a thumb along a thin track, or use the arrow keys. It has a label, a value, and one thumb for each value.

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

## When to use it

Best for: Pick a value, or a range with two or more thumbs, by dragging along a track.

- Use it when people pick a value by feel from a range.
- Pass an array as `value` or `defaultValue` for a range with two or more thumbs.
- Use `tone` for a value that has a meaning, and say the same in words.
- Use `variant="playhead"` or `bare` over a waveform or a timeline. The parent draws the picture.

## When not to use it

- To type an exact number, use an [Input](https://gelatinui.com/components/input.md).
- To show a measured value that people do not set, use a [Meter](https://gelatinui.com/components/meter.md).
- To change one channel of a color, use a [Color Slider](https://gelatinui.com/components/color-slider.md).
- To pick a value on a moving scale, use a [Ruler Slider](https://gelatinui.com/components/ruler-slider.md).
- For a track that stretches, marks that hold the thumb, and end icons, use an [Elastic Slider](https://gelatinui.com/components/elastic-slider.md).

## Notes for agents

- One line renders the root, the control, the track, the indicator, and one thumb per value.
- The children go above the control: `SliderLabel` and `SliderValue`.
- Name the thumbs with a `SliderLabel` or `thumbProps` (`aria-label`, `getAriaLabel`).
- Pass `control` with your own `SliderControl` to change a part, such as a thumb with a Tooltip.
- `onValueChange` keeps the shape of `value`: a number stays a number, and an array stays an array.
- `SliderIndicator` has no motion, because a transition would lag behind the pointer.
- A vertical slider is at least 160px high.

## Anatomy

```text
Slider
├─ SliderLabel (0..n)
├─ SliderValue (0..n)
├─ SliderControl (0..n)
├─ SliderTrack (0..n)
├─ SliderIndicator (0..n)
└─ SliderThumb (0..n)
```

## API reference

### Slider

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `control` | `ReactNode` |  | The control under the children. Default: a `SliderControl` with the track, the indicator, and one thumb per value. Pass your own `SliderControl` to change a part (a thumb with a Tooltip). |
| `thumbProps` | `Omit<SliderThumbProps, "index">` |  | Props for every default thumb: `getAriaLabel`, `getAriaValueText`, `aria-label`, `disabled`. |
| `tone` | `TrackTone` | "neutral" | `default`: the `primary` fill. A status colors the fill and the thumb edge: `success` a good value, `warning` a value that needs care, `info` a neutral mark, `destructive` a value over a limit. Color is never the only signal: say it in words too. |
| `glow` | `boolean` |  | A soft halo in the fill color (`glow`, `@gelatin-ui/glow`). Default: `false`. |
| `variant` | `"bare" \| "default" \| "playhead"` | "default" | `default`: the track, the fill, and round thumbs. `playhead`: an invisible track over the parent's whole box and a 2px line thumb, for a scrub over a waveform or a timeline (the parent draws the played part). `bare`: the same press area with thumbs that the item draws (children of `SliderThumb`), for the handles of a timeline. Default `default`. |

Also takes every prop of Base UI `Slider.Root`: https://base-ui.com/react/components/slider

### SliderLabel

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### SliderValue

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Slider.Value`: https://base-ui.com/react/components/slider

### SliderControl

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### SliderTrack

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### SliderIndicator

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### SliderThumb

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Slider.Thumb`: https://base-ui.com/react/components/slider

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Slider | `slider` | `data-disabled`, `data-orientation` |  |  |
| SliderLabel | `slider-label` |  | `--slider-label-opacity` | `motion-timing` |
| SliderValue | `slider-value` |  | `--slider-value-opacity` | `motion-timing` |
| SliderControl | `slider-control` | `data-disabled`, `data-orientation` |  |  |
| SliderTrack | `slider-track` |  |  |  |
| SliderIndicator | `slider-indicator` |  |  | `motion-timing` |
| SliderThumb | `slider-thumb` | `data-disabled`, `data-dragging`, `data-invalid` |  | `hit-area`, `motion-timing`, `status-colors` |

## Usage

One line renders the root, the control, the track, the indicator, and one thumb per value. The children go above the control.

```tsx title="volume-slider.tsx"
import { Slider, SliderLabel, SliderValue } from "@/components/ui/slider";

export function VolumeSlider() {
  return (
    <Slider defaultValue={40}>
      <SliderLabel>Volume</SliderLabel>
      <SliderValue />
    </Slider>
  );
}
```

## 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/slider
```

It adds 13 registry items: 9 files, 2120 lines, and the npm packages `@base-ui/react`, `clsx`, `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

- [Elastic Slider](https://gelatinui.com/components/elastic-slider.md)
- [Ruler Slider](https://gelatinui.com/components/ruler-slider.md): Pick Ruler Slider to pick a value on a moving scale under a fixed line, such as an angle or a zoom.
- [Color Slider](https://gelatinui.com/components/color-slider.md)
- [Field](https://gelatinui.com/components/field.md)
- [Number Field](https://gelatinui.com/components/number-field.md): Pick Number Field to type an exact number with steps and limits.

## Keyboard

| Keys | Action |
| --- | --- |
| Arrow keys | Changes the value by one `step`. Left and Right follow the direction of the page. |
| Shift + arrow keys, Page Up, Page Down | Changes the value by `largeStep`. |
| Home, End | Goes to the minimum or the maximum. |
| Tab | Moves to the next thumb. |

## Accessibility

It is a Base UI Slider. Each thumb is a native range input, and the arrow keys step the value.

Name the thumbs with a `SliderLabel` or `thumbProps`. Use `getAriaValueText` to read a range as one phrase.

On touch the control is 44px high, and the text stays 14px.

On touch, a swipe across the track scrolls the page and keeps the value. A swipe along it drags, and a tap sets it.

## Motion

| Part | Motion |
| --- | --- |
| Thumb | none · the fill and the thumb follow the pointer with no transition |
