---
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 keys, such as a recording's place, 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 keys, such as a recording's place, 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>/meadow-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 { useState } from 'react';
import { Slider } from '@/components/ui/goop/slider';

function RecordingScrubber({ length }: { length: number }) {
  const [at, setAt] = useState(0);
  const clock = (seconds: number) => `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`;
  return (
    <div className="flex items-center gap-3 text-sm tabular-nums text-muted-foreground">
      <span>{clock(at)}</span>
      <Slider
        className="flex-1"
        aria-label="Recording"
        aria-valuetext={`${clock(at)} of ${clock(length)}`}
        max={length}
        value={at}
        onValueChange={setAt}
      />
      <span>{clock(length)}</span>
    </div>
  );
}

function SampleDepth() {
  return <Slider range aria-label="Sample depth" min={0} max={120} step={5} defaultValue={[20, 60]} />;
}

function MapDetailSetting() {
  const [detail, setDetail] = useState(50);
  return <Slider variant="filled" label="Map detail" value={detail} onValueChange={setDetail} />;
}

function TrailWidth() {
  return (
    <Slider
      aria-label="Trail width"
      icon="globe"
      max={4}
      format={(metres) => `${metres} m`}
      ticks={[0, 2, 4].map((metres) => ({ value: metres, label: `${metres} m` }))}
      preview={(metres) => (metres < 2 ? 'Footpaths only' : 'Footpaths and tracks')}
    />
  );
}
```

- height, width, gap, corner, background, 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]`.
- variant?: 'scrubber' | 'filled' — The look: `scrubber` (default) a thin 4 px track with an upright thumb, as a recording's place; `filled` a 40 px bar filled to the value with a grab at the fill's end and its `label` inside, as a setting's level.
- value?: number | readonly [number, number] — The value, controlled: one number from `min` to `max`; one outside draws the nearer end. Or: The values, controlled: `[low, high]`, each from `min` to `max`.
- defaultValue?: number | readonly [number, number] — The value at first, uncontrolled (default `min`); one outside the range draws the nearer end. 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: each key, each move of a drag, 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: when a drag is released, and after each key that changed it. 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", following every change. Or: A line under the track: the caller's words for the span, following every change.
- id?: string — The root's id.
- ref?: Ref<HTMLSpanElement> — The root element (the press target).
- className?: string — Classes for the root, last: a width, a margin, `flex-1` in a row.
- min?: number = 0 — The lowest value (default 0).
- max?: number = 100 — The highest value (default 100).
- step?: number = 1 — The distance one arrow key moves a value (default 1); PageUp and PageDown move ten; a press or a drag snaps to it.
- name?: string — The name the value is sent under in a form (a range sends two, as `name[]`).
- form?: string — The id of the form the value is sent with, where the slider sits outside it.
- disabled?: boolean — Off: no key, press or drag moves it, no thumb is a tab stop, and the slider is dimmed once.
- aria-label?: string — The thumb's accessible name; a range's thumbs add ", minimum" and ", maximum".
- aria-labelledby?: string — The id of the element whose words name the thumb; handed to each thumb.
- aria-describedby?: string — The ids of the elements whose words describe the thumb; handed to each thumb.
- aria-valuetext?: string — The value in words where the number alone says too little ("0:12 of 0:58"); handed to the thumb.
- format?: (value: number) => string — How a value reads to a reader ("60%", "$7,400"): each thumb's spoken value; an `aria-valuetext` wins over it.
- ticks?: ReadonlyArray<number | SliderTick> — Marks on the track at these values (those from `min` to `max`); one with a `label` adds the labels row under it.
- icon?: IconName — A pack icon name before the track, hidden from a reader (`"volume"`).
- label?: ReactNode — The slider's words, naming the thumb unless `aria-label` or `aria-labelledby` does: inside a filled bar at its start; over a scrubber (or a range) a header row, the words at its start and the value, in `format`, at its end.
- Also takes: dir?: 'ltr' | 'rtl'
- State: value (value / defaultValue / onValueChange); drawn by data-focus-visible, data-disabled, data-filled
- Types: SliderTick = { value: number; label?: ReactNode }

## Keyboard

- ArrowLeft / ArrowRight: step value
- ArrowUp / ArrowDown: step value
- PageUp / PageDown: step value by ten steps
- Home / End: jump to bound

## Accessibility

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

## 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/meadow/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 framed row.
- [Rating](/themes/meadow/components/rating): A row of stars to give a score, or to show an average with halves, for reviews, testimonials and feedback.
- [Color picker](/themes/meadow/components/color-picker): A painted area and channel sliders that choose one colour.
- [File upload](/themes/meadow/components/file-upload): A drop zone or a button to choose files, for attachments, an import or a photo, with a list of the chosen files.
