At a glance
- DtSlider supports single values and ranges, horizontal and vertical layouts, ticks, marks, and
startandendslots. - Each thumb uses a native
<input type="range">for keyboard navigation, focus, form submission, and screen reader semantics. - The default
tooltipreadout shows the value without reserving layout space or being clipped by a parent container. Usealwaysto keep it visible, orneverto hide it. - Use
stepfor fixed increments andsnapPointsfor a magnetic pull toward anchor values when clicking, tapping, or dragging. - It supports right-to-left (RTL) layouts and dark mode, and respects reduced-motion settings. Each thumb has a 44×44px touch target.
- Storybook
Meet DtSlider
Pass a number to modelValue for one thumb, or an array of two numbers for a range. The examples below show both modes and the start and end slots.
Anatomy
Select a part below to highlight it on the slider.
| Part | What it is | Controlled by |
|---|---|---|
| Label | Names the slider for everyone, including screen readers. | label, show-label, #label slot |
| Start and end slots | Optional content at either end of the track (e.g., icons). | #start, #end |
| Track | The full scale, from minimum to maximum. | n/a (themed with tokens) |
| Indicator | The filled span, starting from either end or a value you choose. | fill-origin |
| Ticks | Small dots along the track at every step or at a regular interval. | show-ticks |
| Marks | Text labels at key positions. | show-marks |
| Thumb | The draggable control, with a 44×44px hit area larger than the visible thumb. | v-model |
| Readout | The current value. A tooltip appears on hover, focus, or drag by default. With readout="always", it sits below the track, as shown here. | readout |
When to use a slider
| If people need to… | Use |
|---|---|
| Pick an approximate value from a range (e.g., volume, brightness, a percentage) | DtSlider |
| Filter by a numeric range where precision isn't critical (e.g., price, duration) | DtSlider with two thumbs |
| Enter an exact number | DtInput |
| Choose from a small set of discrete options (about five or fewer) | DtRadioGroup or DtSelectMenu |
| Switch something on or off | DtToggle |
When both feel and precision matter, pair the slider with number inputs bound to the same value. This works especially well on touch devices, where dragging to an exact value is harder.
Values, ticks, marks, and snapping
Ticks and marks
Ticks are small dots along the track. Set show-ticks to true to follow step, or pass a number to set a different interval. Marks are text labels set with show-marks: pass true to label min and max, or an array for specific values. Neither changes which values users can select.
On a fine-grained scale, pair frequent ticks with sparse marks to avoid clutter.
Steps and magnetic snapping
step sets the increment between values. snapPoints pulls the thumb toward anchor values, like snapping to guides in a design tool. Pass a number for evenly spaced snap points, or an array for specific values.
Snapping applies to clicks, taps, and dragging; keyboard navigation follows step.
Drag the first slider onto 25, then away again. Notice how it holds near 25 before releasing.
The value readout
The readout prop controls when and where the current value appears:
tooltip(default): appears above the thumb on hover, focus, or drag. It reserves no layout space, which suits forms and toolbars.always: stays visible below the track. Use it when users need to see the value without interacting, such as on a dashboard.never: hides the readout. Use it when you display the value elsewhere on the page.
The floating readout requires the browser's Popover API. Use readout="always" when supporting browsers without it.
Readouts and screen reader announcements share the same value formatting. Use prefix and suffix to add text around the value (e.g., suffix="%"), or getValueText for custom formatting.
Accessibility and the native input
Each thumb is a visually hidden native <input type="range">. The browser provides:
- The slider role and its minimum, maximum, and current value.
- Tab order and focus.
- Arrow keys, Home, and End.
- Quantizing to
stepand clamping tominandmax. - Form behavior: set
nameto include the value in a form submission. In range mode, both thumbs share the name; read both values in[low, high]order withFormData.getAll(name).
DtSlider supports two thumbs for ranges. Page Up, Page Down, and Shift + Arrow move by largeStep, rounded to a whole number of steps (at least one).
Give every slider a label. For a range, pass getValueText so screen readers distinguish the thumbs (e.g., "Minimum: $20" and "Maximum: $70").
What DtSlider isn't for
- DtSlider doesn't represent steps in a multi-step flow.
- To show progress, such as upload status, use DtProgressCircle.
- DtSlider isn't built for audio or video seeking, where the control also tracks playback position.
See the full component documentation for all prop values, demos, and usage guidance.
