---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Slider

A value or a span chosen by dragging a thumb along a track or with the arrow keys, such as a volume or a price limit, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `Slider`.

## Try it

Drag the thumb or use the arrows, PageUp/PageDown, Home and End; switch to a range, change the step and the format, add ticks, an icon or a header label, disable it.

The value, moving and settled, is only written under it.

## When to use

- A value or a span chosen by dragging a thumb along a track or with the arrow keys, such as a volume or a price limit.
- Also called: range input.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Slider on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-slider.json --yes
```

```text
Add the Goop Slider to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { Slider } from '@/components/ui/goop/slider';

<>
  <Slider defaultValue={40} min={0} max={100} step={5} icon="volume" aria-label="Volume" onValueCommit={send} />
  <Slider
    range
    label="Price"
    defaultValue={[20, 80]}
    format={(value) => `$${value}`}
    preview={([low, high]) => `${Math.round(((high - low) / 100) * 32)} of 32 items in this range`}
  />
</>
```

- Fits: settings (its recipe).
- height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.

## API reference

### Slider: every option

```tsx
import { Slider } from '@/components/ui/goop/slider';
```

### Options

- range?: false | true — Two thumbs instead of one: the value is `[low, high]`.
- value?: number | readonly [number, number] — The value, controlled, from `min` to `max`. Or: The values, controlled: `[low, high]`.
- defaultValue?: number | readonly [number, number] — The value at first, uncontrolled (default `min`). Or: The values at first, uncontrolled (default `[min, max]`).
- onValueChange?: ((value: number) => void) | ((value: [number, number]) => void) — Called with the new number on every change (a key, a drag's move, a press on the track). Or: Called with `[low, high]` on every change.
- onValueCommit?: ((value: number) => void) | ((value: [number, number]) => void) — Called with the number a person settled on: a drag released, or a key. Or: Called with the `[low, high]` a person settled on.
- preview?: ((value: number) => ReactNode) | ((value: readonly [number, number]) => ReactNode) — A line under the track: the caller's words for the value, such as "22 of 32 items". Or: A line under the track: the caller's words for the span.
- id?: string — The root's id.
- ref?: Ref<HTMLSpanElement> — The root element (the press target).
- className?: string — Classes for the outermost element, last: a width, a margin.
- min?: number = 0 — The lowest value.
- max?: number = 100 — The highest value.
- step?: number = 1 — The distance one arrow key moves a value; a press or a drag snaps to it.
- name?: string — The name the value is sent under in a form.
- form?: string — The id of the form the value is sent with, where the slider sits outside it.
- disabled?: boolean — Off: nothing moves it, no thumb is a tab stop, and it is dimmed.
- format?: (value: number) => string — How a value reads in the bubble, the header and to a reader ("60%", "$7,400"); grouped digits by default.
- label?: ReactNode — A header row over the track, the label at its start and the value at its end, naming the thumb.
- ticks?: ReadonlyArray<number | SliderTick> — Marks on the track at these values; one with a `label` adds the labels row under it.
- icon?: IconName — A pack icon name before the track, hidden from a reader (`"volume"`).
- aria-label?: string — The thumb's accessible name.
- aria-labelledby?: string — The id of the element that names the thumb.
- aria-describedby?: string — The ids of the elements that describe the thumb (a Field's description).
- aria-valuetext?: string — The value in words where the number says too little ("40 percent"); `format`'s by default.
- Also takes: dir?: 'ltr' | 'rtl'
- State: value (value / defaultValue / onValueChange); drawn by data-disabled
- Types: SliderTick = { value: number; label?: ReactNode }

## Keyboard

- ArrowRight / ArrowUp: raise the value by one step (in a range, never past the other thumb; the focus stays)
- ArrowLeft / ArrowDown: lower the value by one step (in a range, never past the other thumb; the focus stays)
- PageUp / PageDown: raise or lower the value by ten steps (in a range, never past the other thumb; the focus stays)
- Home: set the focused thumb's lowest value (in a range the high thumb stops at the low one), the focus staying
- End: set the focused thumb's highest value (in a range the low thumb stops at the high one), the focus staying

## Accessibility

- The behaviour layer under the part answers keys, focus and dismissal: never write your own.
- hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing
- disabled: the attribute data-disabled

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Segmented control](/themes/trail/components/segmented-control): One choice of two to five short options that applies at once — a view or a mode — drawn as touching segments in one pill.
- [Rating](/themes/trail/components/rating): A row of stars to give a score, or to show an average with halves, for reviews and feedback.
- [Color picker](/themes/trail/components/color-picker): A painted area and channel sliders that choose one colour.
- [File upload](/themes/trail/components/file-upload): A drop zone or a button to choose files, with a list of the chosen files and their sizes, for attachments, imports or a photo.
