Installation
npx logic2b@next add sliderUsage
import { Slider } from "@/components/ui/slider"
<Slider aria-label="Volume" defaultValue={[50]} max={100} step={1} />
Usage notes
Built on Radix Slider.Root. Values are always arrays, so a single-thumb
slider uses [value] and a range uses [start, end].
Examples
Range
Controlled
40
Vertical
Accessibility
- Each thumb is a
sliderrole element that is fully keyboard operable. Arrowkeys move bystep;Page Up/Page Downmove by a larger increment;Home/Endjump tomin/max.- Give the control a contextual
aria-label, or pointaria-labelledbyat the id of a visible label, so screen readers announce its purpose. - For a range, use
thumbLabels(for example["Minimum price", "Maximum price"]) when the generated numbered names are not descriptive enough. - On range sliders each thumb is focusable independently and cannot cross past its neighbor.
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<Slider
defaultValue={[40]}
min={0}
max={100}
aria-label="Volume"
/>API reference
Generated from the public TypeScript exports in src/ui/slider.tsx.
Slider
ComponentProps: SliderProps| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
min | number | No | 0 | — |
max | number | No | 100 | — |
thumbLabels | string[] | No | — | — |
aria-label | string | No | "Slider value" | — |
Accessibility contract
Machine-readable behavior and consumer responsibilities for slider.
- Support
- Primitive-managed
- Pattern
- slider
- Radix Slider
| Keys | Behavior |
|---|---|
| ArrowUp ArrowDown ArrowLeft ArrowRight | Move within the composite control. |
| Home End PageUp PageDown | Move the focused thumb by the supported increment. |
Built-in semantics
- Each thumb exposes slider value/min/max semantics and supports range sliders.
Consumer responsibilities
- Provide a contextual aria-label or aria-labelledby for every thumb.