Slider
A value, or a range of values, chosen by dragging.
Installation
npx shadcn@latest add https://qure-ui.qure.ai/r/slider.jsonUsage
import {
Slider, SliderControl, SliderIndicator, SliderLabel, SliderThumb, SliderTrack, SliderValue,
} from '@/components/ui/slider'<Slider defaultValue={65}>
<SliderControl>
<SliderTrack>
<SliderIndicator />
<SliderThumb aria-label="Overlay opacity" />
</SliderTrack>
</SliderControl>
</Slider>A slider is for a value whose exact number does not matter much — opacity, brightness, a confidence threshold being tuned by eye. When the number does matter, and especially when it will be typed or audited, use a Number Field: a slider cannot be dictated, cannot be pasted, and rounds whatever the user meant to the nearest step.
Composition
<Slider> {/* owns the value, min/max/step, orientation */}
<SliderLabel> {/* names the control */}
<SliderValue> {/* an <output>, announced as it changes */}
<SliderControl> {/* the pointer target — full field height */}
<SliderTrack> {/* the thin bar */}
<SliderIndicator /> {/* the filled part */}
<SliderThumb /> {/* one per value; positions itself in the track */}
</SliderTrack>
</SliderControl>
</Slider>The thumb is a child of the track and positions itself absolutely against it, so the track must
not be overflow-hidden — clipping the overflow clips the thumb. The control is deliberately
taller than the track: a 6px pointer target would fail WCAG 2.5.8, and a thick track to fix that
would be a worse-looking slider.
aria-label goes on SliderThumb, not on Slider. The thumb owns the hidden range input a
screen reader actually reads; a label on the root wrapper is announced on a group and leaves
the input unnamed.
With a readout
SliderValue takes a render function receiving the formatted strings and the raw numbers, so
the unit lives with the value rather than in the label. It renders an <output>, which is
announced as it changes without a live region of your own.
Range
Pass an array and you get one thumb per entry. This is the natural shape for a CT window — a
lower and an upper Hounsfield bound that only mean anything together. minStepsBetweenValues
stops the two thumbs collapsing onto each other, and thumbCollisionBehavior decides whether
they push, swap or block when they meet.
Size
The control row is the field height — 32, 40 or 48 — so a slider lines up with an Input beside it. The track and thumb scale with it.
Vertical
orientation="vertical" for controls that map to something vertical on screen, or for a pair of
window controls beside a viewport. The parent has to give it a height; the slider fills it.
Keyboard
Arrow keys step, shift and Page Up/Page Down move by largeStep (10 by default), Home and End
jump to the bounds. On a range slider each thumb is separately focusable.
API Reference
Everything Base UI's Slider accepts, plus:
Prop
Type
The ones you will reach for on the root:
Prop
Type