Slider is a generic range input primitive. It manages value, pointer tracking, and drag interactions. Domain-specific sliders like TimeSlider and VolumeSlider extend this with media-specific bindings.
Sub-components
| Component | Description |
|---|---|
Slider.Root | Root slider container. Manages value, drag, and keyboard state. |
Slider.Track | Visual track bar that receives click-to-seek. |
Slider.Fill | Fill bar that represents the current value. |
Slider.Buffer | Buffer bar that represents buffered amount (used in TimeSlider). |
Slider.Thumb | Draggable thumb handle. |
Slider.Preview | Container for pointer-position-anchored previews. |
Slider.Value | Displays a formatted value at the current or pointer position. |
Slider.Thumbnail | Displays a thumbnail image inside a preview at the pointer position. |
Import
Basic Usage
With Preview
Slider.Root Props
Current slider value. The slider is uncontrolled when omitted. Defaults to
0.Minimum allowed value. Defaults to
0.Maximum allowed value. Defaults to
100.Step size for arrow key navigation. Defaults to
1.Large step size for
Page Up / Page Down key navigation. Defaults to 10.Slider orientation. Defaults to
"horizontal".Disables the slider.
Controls how the thumb aligns relative to the track edges at min/max positions.
aria-label for the slider. Announced by screen readers.Called continuously as the value changes during drag.
Called once when the user commits a value (on drag end or keyboard interaction).
Called when the user begins dragging the thumb.
Called when the user releases the thumb after dragging.
CSS class name or a function that receives state and returns a class name.
Inline style or a function that receives state and returns a style object.
Custom render prop for the root element.
Slider.Value Props
Which value to display.
"current" shows the committed value; "pointer" shows the value at the current pointer position (for hover previews).State Data Attributes
These attributes are reflected onSlider.Root.
| Attribute | Value / Description |
|---|---|
data-pointing | Present while the pointer is hovering over the slider. |
data-interactive | Present when the user is interacting (pointing or dragging). |
data-dragging | Present while the thumb is being dragged. |
data-orientation | "horizontal" | "vertical" — reflects the orientation prop. |
CSS Custom Properties
| Property | Description |
|---|---|
--media-slider-fill | Current fill percentage (0–100). Use to position fill and thumb elements. |
--media-slider-pointer | Pointer position percentage (0–100). Use to position preview elements. |
CSS Styling Example
Accessibility
Renders withrole="slider" and automatic ARIA attributes (aria-valuemin, aria-valuemax, aria-valuenow, aria-valuetext). Override the label with the label prop. Keyboard controls:
Arrow Left/Arrow Right: step bystepPage Up/Page Down: step bylargeStepHome: jump to minimumEnd: jump to maximum