npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-slider.json --yesSlider
ProA 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.
What an agent sees
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')}
/>
);
}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.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-slider.json --yesAdd the Goop Slider to this project. The install steps are at https://goop.so/docs/install.mdUsage
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
- Each option with its sentence: slider--options.md
- State: value (value / defaultValue / onValueChange); drawn by data-focus-visible, data-disabled, data-filled
- data-slot values (to select a part by): slider, slider-field, slider-grab, slider-grab-bar, slider-header, slider-icon, slider-label, slider-preview, slider-range, slider-thumb, slider-thumb-bar, slider-tick, slider-tick-label, slider-tick-labels, slider-ticks, slider-track, slider-value
Slider: every option
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;filleda 40 px bar filled to the value with a grab at the fill's end and itslabelinside, as a setting's level. - value?: number | readonly [number, number] — The value, controlled: one number from
mintomax; one outside draws the nearer end. Or: The values, controlled:[low, high], each frommintomax. - 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-1in 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-valuetextwins over it. - ticks?: ReadonlyArray<number | SliderTick> — Marks on the track at these values (those from
mintomax); one with alabeladds 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-labeloraria-labelledbydoes: inside a filled bar at its start; over a scrubber (or a range) a header row, the words at its start and the value, informat, 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
| Key | What it does |
|---|---|
| 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
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| 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.