Slider
Currently only available in React.
Single-value or two-thumb range slider with pointer drag and full keyboard support. Horizontal or vertical, optionally inverted. The component renders track / fill / thumb as inner <span> elements with data-part attributes so you can style them via Tailwind arbitrary selectors (or any CSS).
Features
Single-value or two-thumb range mode via
range prop.Pointer drag with snap-to-step.
Full keyboard support: Arrows, PageUp / PageDown, Home / End.
Horizontal or vertical orientation, optionally inverted.
Range thumbs cannot pass each other.
Example
Volume40%
Price range$20 – $80
Anatomy
import { Slider } from '@wire-ui/react'
<Slider defaultValue={40} min={0} max={100} step={1} aria-label="Volume" />
<Slider range defaultValue={[20, 80]} min={0} max={100} step={5} aria-label="Price range" />Styling
Slider renders three inner parts: [data-part=track], [data-part=fill], and [data-part=thumb]. Target them with Tailwind arbitrary selectors or plain CSS. Each thumb additionally carries data-thumb-index="0" / "1" for range sliders.
<Slider className="
[&_[data-part=track]]:bg-[#e5e5e5]
[&_[data-part=fill]]:bg-black
[&_[data-part=thumb]]:size-4
[&_[data-part=thumb]]:bg-white
[&_[data-part=thumb]]:border
" />Using data attributes
The root receives data-orientation ("horizontal" / "vertical") and data-disabled. Thumbs receive data-part="thumb" and data-disabled when the slider is disabled.
[data-orientation="horizontal"] [data-part="track"] { height: 4px; width: 100%; }
[data-orientation="vertical"] [data-part="track"] { width: 4px; height: 100%; }
[data-part="thumb"][data-disabled] { opacity: 0.5; cursor: not-allowed; }Single-value props
| Prop | Type | Default | Description |
|---|---|---|---|
range | false | false | Single thumb mode |
value | number | — | Controlled value |
defaultValue | number | min | Initial value (uncontrolled) |
onChange | (value: number) => void | — | Called when the value changes |
Range props
| Prop | Type | Default | Description |
|---|---|---|---|
range | true | required | Two-thumb range mode |
value | [number, number] | — | Controlled [start, end] |
defaultValue | [number, number] | [min, max] | Initial value (uncontrolled) |
onChange | (value: [number, number]) => void | — | Called when either thumb moves |
Shared props
| Prop | Type | Default | Description |
|---|---|---|---|
min | number | 0 | Minimum value |
max | number | 100 | Maximum value |
step | number | 1 | Step increment |
orientation | 'horizontal' | 'vertical' | 'horizontal' | Layout orientation |
disabled | boolean | false | Disable the slider |
inverted | boolean | false | Reverse direction |
aria-label | string | — | Accessible name |
Data attributes
| Attribute | Element | Values |
|---|---|---|
data-orientation | Root | "horizontal" / "vertical" |
data-disabled | Root, Thumb | Present when disabled |
data-part | Inner spans | "track" / "fill" / "thumb" |
data-thumb-index | Thumb | "0" (lower) / "1" (upper, range only) |
Accessibility
- Each thumb is a focusable
<span>withrole="slider"andaria-valuemin/aria-valuemax/aria-valuenow. aria-orientationreflects theorientationprop.- Range sliders set
role="group"on the root with the providedaria-label. - Always provide
aria-label(oraria-labelledby) for non-range sliders.
Keyboard Interactions
| Key | Description |
|---|---|
| ArrowUp / ArrowRight | Increment by step (direction adjusts for orientation + inverted). |
| ArrowDown / ArrowLeft | Decrement by step (direction adjusts for orientation + inverted). |
| PageUp | Increment by step * 10. |
| PageDown | Decrement by step * 10. |
| Home | Jump to min. |
| End | Jump to max. |
Last updated on