Slider
ExpressiveChooses a value or a range on a continuous or stepped scale, in five sizes.
import { Slider, RangeSlider } from '@windmorph/react';Props
Slider 25 props
The track's thickness, from XS (a 16px track) to XL.
The direction the slider runs. Vertical sliders run bottom to top and default to 240px tall.
The lowest value.
The highest value.
The amount the value changes by in one step.
Discrete: show a stop indicator at every step (use a coarse
step).Turns the slider off: it can't be moved or focused.
Show the value above the thumb while it is dragged or keyboard-focused.
Formats the value for the value indicator, and for assistive tech unless
valueTextsays it in words.The value in words for assistive technology, each thumb's
aria-valuetext, where a number format can't say it (a time:(seconds) => '1 minute 23 seconds of 10 minutes'), given the thumb's index too (0, or 1 for a range's end). Without it the value is read asformatOptionsformats it; the value indicator keeps that format.Form field name (one hidden input per thumb).
The id of the slider's root, its
group(an error summary can link to it).Ref to the root
<div>element.The value (controlled).
The initial value when uncontrolled.
Fill the track from its centre (for values around a midpoint). M3 doesn't use inset icons on centred sliders, so
leadingIconandtrailingIconare ignored.An icon inside the active track at its start (sizes md and up; ignored, with a dev warning, on xs and sm). When the active track is too short for it, it moves to the start of the inactive track.
An icon inside the inactive track at its end (sizes md and up; ignored on xs and sm).
Events
Called as the value changes, while dragging too.
Called when the user stops dragging or releases a key.
Text
Accessible name when there's no visible label.
One of
aria-labeloraria-labelledbyis required.The id of the visible label that names the slider.
One of
aria-labeloraria-labelledbyis required.
Classes for the root element, merged with
classNames.root; consumer classes win.Inline styles for the root element.
Classes for each part, by slot.
classNames.rootis merged withclassName.The outer element.
The track, holding the active and inactive segments and the stop indicators.
Each active track segment (the filled part, from the start or the centre).
Each inactive track segment.
The stop indicators: at the track's ends, and at every step with
ticks.The inset icons (
leadingIcon,trailingIcon).Each thumb, the pressable area around its handle.
The handle bar drawn inside each thumb.
The value indicator above a thumb (
valueLabel).
Also accepts the root element's HTML attributes (id, data-*, event handlers).
RangeSlider 23 props
The track's thickness, from XS (a 16px track) to XL.
The direction the slider runs. Vertical sliders run bottom to top and default to 240px tall.
The lowest value.
The highest value.
The amount the value changes by in one step.
Discrete: show a stop indicator at every step (use a coarse
step).Turns the slider off: it can't be moved or focused.
Show the value above the thumb while it is dragged or keyboard-focused.
Formats the value for the value indicator, and for assistive tech unless
valueTextsays it in words.The value in words for assistive technology, each thumb's
aria-valuetext, where a number format can't say it (a time:(seconds) => '1 minute 23 seconds of 10 minutes'), given the thumb's index too (0, or 1 for a range's end). Without it the value is read asformatOptionsformats it; the value indicator keeps that format.Form field name (one hidden input per thumb).
The id of the slider's root, its
group(an error summary can link to it).Ref to the root
<div>element.The range, as
[start, end](controlled).The initial range when uncontrolled.
Events
Called as the range changes, while dragging too.
Called when the user stops dragging or releases a key.
Text
Accessible name when there's no visible label.
One of
aria-labeloraria-labelledbyis required.Words the range slider announces (its thumbs' names), with English defaults. A
LabelsProvidersets them for the whole app.The id of the visible label that names the slider.
One of
aria-labeloraria-labelledbyis required.
Classes for the root element, merged with
classNames.root; consumer classes win.Inline styles for the root element.
Classes for each part, by slot.
classNames.rootis merged withclassName.The outer element.
The track, holding the active and inactive segments and the stop indicators.
Each active track segment (the filled part, from the start or the centre).
Each inactive track segment.
The stop indicators: at the track's ends, and at every step with
ticks.The inset icons (
leadingIcon,trailingIcon).Each thumb, the pressable area around its handle.
The handle bar drawn inside each thumb.
The value indicator above a thumb (
valueLabel).
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Tokens
M3's component tokens as CSS variables. Each is unset until you set it, on :root, a theme or any ancestor, and falls back to the default shown. The root carries data-variant (and data-size where it has sizes), which picks the variables that apply. See Component tokens in the Customisation guide.
| Variable | Default | Paints | Compose |
|---|---|---|---|
--md-comp-slider-active-track-color | var(--md-sys-color-primary) | The track between the start (or the other thumb) and the handle. | SliderTokens.ActiveTrackColor |
--md-comp-slider-inactive-track-color | var(--md-sys-color-secondary-container) | The rest of the track. | SliderTokens.InactiveTrackColor |
--md-comp-slider-handle-color | var(--md-sys-color-primary) | The handle. | SliderTokens.HandleColor |
--md-comp-slider-stop-indicator-color | var(--md-sys-color-on-secondary-container) | The stop indicators and tick marks on the inactive track. | SliderTokens.StopIndicatorColor |
--md-comp-slider-value-indicator-container-color | var(--md-sys-color-inverse-surface) | The value indicator’s container. | SliderTokens.ValueIndicatorContainerColor |
--md-comp-slider-value-indicator-label-label-text-color | var(--md-sys-color-inverse-on-surface) | The value indicator’s text. | SliderTokens.ValueIndicatorLabelTextColor |
Spec status
Built to the M3 Expressive slider spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.
| Item | Status | Details |
|---|---|---|
| Standard | Built | Variant · Sizes |
| Centered | Built | Variant · Discrete |
| Range | Built | Variant · Range |
| Discrete | Built | Variant · Discrete |
| Orientation: horizontal and vertical | Built | Configuration · Sizes, Vertical |
| Size: XS to XL | Built | Configuration · Sizes |
| Inset icon | Built | Configuration · Value label |
| Stops | Built | Configuration · Discrete |
| Value indicator | Built | Configuration · Value label |
| Haptics | Differs | There are no haptics. A press on a discrete track maps through the corner inset its stops are drawn with, so a tap on a drawn stop selects that stop. |
trailingIcon | Extension | A second inset icon at the inactive track's end (from Material Components Android); the spec shows one inset icon. |
formatOptions | Extension | Formats the value indicator and what assistive tech announces, e.g. as a percentage. |
Standard
BuiltVariant · Sizes
Centered
BuiltVariant · Discrete
Range
BuiltVariant · Range
Discrete
BuiltVariant · Discrete
Size: XS to XL
BuiltConfiguration · Sizes
Inset icon
BuiltConfiguration · Value label
Stops
BuiltConfiguration · Discrete
Value indicator
BuiltConfiguration · Value label
Haptics
DiffersThere are no haptics. A press on a discrete track maps through the corner inset its stops are drawn with, so a tap on a drawn stop selects that stop.
ExtensiontrailingIconA second inset icon at the inactive track's end (from Material Components Android); the spec shows one inset icon.
ExtensionformatOptionsFormats the value indicator and what assistive tech announces, e.g. as a percentage.
Bundle size
Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.
Slider,RangeSlider: 16.0 kB
M3 Expressive specs
- Sizes
xs, sm, md, lg, xl
Differences from Compose
- Compose ships one size (16px track, 44px handle); the Expressive sizes
xs–xlfollow the M3 spec's measurements — tracks 16 / 24 / 40 / 56 / 96px, handles 44 / 44 / 52 / 68 / 108px. - Active track and handle are
primary, the inactive tracksecondary-container; the 4px handle narrows to 2px while pressed, dragged or keyboard-focused, with a gap each side. - The track geometry ports Compose's
drawTrackas CSS length expressions, so the first server render is exact and resizing needs no measuring; range and centred tracks carry stop indicators at both ends. - Stop indicators and ticks use the M3 token table's colours, not Compose's code:
on-primaryon the active track andon-secondary-containeron the inactive one (disabled,inverse-on-surfaceandon-surfaceat 38%). - Inset icons follow MDC — a
leadingIcon10px inside the active track's start and antrailingIcon10px inside the inactive end (replacing the stop) on sizes md and up. When the active track is too short for the start icon, it moves to the start of the inactive track (M3). Centred sliders and XS / S sliders ignore inset icons (with a development warning), as M3 advises. The value indicator pill is not in Compose's default slider. - On touch screens it behaves like Compose's draggable slider: a swipe across the slider scrolls the page and leaves the value alone, a tap on the track sets the value when the finger lifts, and a drag along the track moves the nearest thumb once it passes 8px. Mouse presses set the value at once.
- Deviation: there are no haptics. A press on a discrete track maps through the same corner inset its stops are drawn with, so a tap on a drawn stop selects that stop at every size.