Slider
Picks a value within a continuous range, from a list of stops (data-ts-slider-values), or a span with two thumbs that can’t cross (data-ts-slider-range). It’s built on native <input type="range"> elements, so dragging and keyboard behavior come from the browser. It can show the current value and the min/max marks, run vertically (is-vertical), or be read-only.
Forms · TaishoDS Core, in plain HTML.
Examples
One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.
Plan seat limit
Price range
Vertical
Read-only
Uneven stops
Text per stop
Class reference
Every value of each modifier, with its HTML ready to copy.
Size
Control thickness: sm, md, or lg.
States
is-disabled blocks dragging; is-readonly can be focused and read but doesn’t change.
Range
is-range adds two handles that can’t cross; the span between them is filled.
Orientation
is-vertical puts the minimum at the bottom.
When to use
- The value is approximate and visual feedback on the range helps (volume, opacity, a threshold).
- Where the value sits in the range matters more than the exact number.
- Dragging to adjust feels more natural than typing.
- You filter by a span (price, usage quota, a range of deployment dates). Use
data-ts-slider-range, with two thumbs. - The possible values follow an uneven scale (plan seats: 5, 10, 25, 50, 100, 250).
data-ts-slider-valueslists the stops, and the control only lands on them.
When not to use
- You need an exact number →
number-input. - The range is huge and dragging is imprecise →
number-input. - It’s a few discrete options (Free, Pro, Enterprise) →
segmented-control.
Do
- Show the current value and the end marks for reference.
- With stops, give each one its text (
data-ts-slider-formatordata-ts-slider-texts). The screen reader says “6 px, Suave,” not a position. - Pick a
stepthat doesn’t frustrate—neither too fine nor too coarse. - Save or fetch data when the value is committed.
ts:commitfires on release;ts:changefires on every movement. - Use
aria-readonly="true"on the input, notdisabled, when the value is shown and submitted with the form but can’t be edited.
Don’t
- Don’t use it when precision matters and mistakes are costly.
- Don’t hide the value. Without a number, the user is guessing.
- Don’t send a request for every change during a drag.
Related
TaishoDS Core
Needs Core’s JS, which hooks in through data-ts-* attributes.
It uses a native <input type="range"> for dragging and the keyboard. Core adds the track fill, the range handle limits, and the events.
Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.
data-ts-sliderdata-ts-slider-formatdata-ts-slider-raildata-ts-slider-rangedata-ts-slider-valuedata-ts-slider-valuesdata-ts-slider-valuetexts
What it does: On every move, Core updates the fill, aria-valuenow, each handle’s ARIA limits, and the value text. range handles don’t cross, and when they overlap, the one with room to move stays on top. Clicking or dragging on the rail moves the nearest handle. form.reset() repaints the fill.
| Attribute | What it does |
|---|---|
data-ts-slider | The component’s root. |
data-ts-slider-range, data-ts-slider-rail | Two handles. The root takes data-ts-slider-range, and there’s a data-ts-slider-rail rail. The fill is painted with --ts-slider-fill, or with --ts-slider-from and --ts-slider-to on the rail. |
data-ts-slider-values | The stops, comma-separated (0,2,4,6,8,12,16,24), in ascending order. With them the <input type="range"> works in positions (min="0", max="n-1", step="1", value = position), and Core publishes the real value in aria-valuenow, aria-valuetext, the visible text, and the events. Page Up and Page Down move one stop (with more than 14 stops, a tenth of the list). To submit the value with the form, put the name on an <input type="hidden"> (one per handle) that Core keeps current, not on the range. |
data-ts-slider-valuetexts, data-ts-slider-valuetext | What the screen reader says (aria-valuetext) when it needs to say more than the visible value. data-ts-slider-valuetexts is a list with one text per stop, separated by | (6 px, Soft); data-ts-slider-valuetext is a template with {v}. Without them, the screen reader says what is shown. |
data-ts-slider-texts | One text per stop, separated by | (0 px|2 px|6 px, Soft), in the order of data-ts-slider-values. It takes precedence over data-ts-slider-format. |
slider-ticks | A <div class="ts slider-ticks" aria-hidden="true"> with one empty <span> per stop, right before the input (or the first input of a range), draws a tick per stop on the rail. |
data-ts-slider-format | The value text, with {v}. It’s also used for aria-valuetext. |
aria-readonly="true" (on the input) | The slider is read-only. It doesn’t change or fire events. |
is-vertical | Makes it vertical. |
ts:change | Fires on every move and is cancelable (the handle snaps back). Carries detail.value (a number, or [inicio, fin] with range) and index. |
ts:commit | Fires when the pointer or the key is released. |
From the CDN, without a build, load taisho.slider.css along with taisho.base.css. That file is all you need.
For how Core works in general, see Behavior.
Accessibility
Implements the Slider pattern from the WAI-ARIA APG.
- It’s built on a native
<input type="range">, so arrow keys, Home/End, and focus are accessible out of the box. - The label is associated through
for/id. - With
data-ts-slider-format, each handle exposesaria-valuetext(for example, “40%”). Without a format, the screen reader reads the number. - With stops, the native input works in positions, but each handle exposes the real value in
aria-valuenowand the stop’s text inaria-valuetext(always, even with no format;data-ts-slider-valuetextsordata-ts-slider-valuetextset it apart from the visible text). The screen reader says “6 px, Soft,” not “position 3.” The stop ticks (slider-ticks) arearia-hidden. - With no visible label, the name comes from
aria-labelon the input. With a visible label, the label wins. - With
is-range, it’s arole="group"named by the label, and each handle is named “<label> Minimum” or “<label> Maximum”. Following the APG Slider (Multi-Thumb) pattern, the start handle’saria-valuemaxis the end handle’s value, and the end handle’saria-valueminis the start handle’s. - The handles don’t cross. A handle that would go past the other one stops at it. When they overlap, the one that can move toward the free side stays on top.
is-readonlyexposesaria-readonly="true". The handle can be focused and read, but neither the keyboard nor the pointer changes it. It doesn’t usedisabled, so the value is still submitted with the form.is-verticalexposesaria-orientation="vertical". The minimum is at the bottom.- With
forced-colors: active, the filled range paints withHighlightand the rest withGrayText, and focus is a system outline (box shadows are lost).
Keyboard
On top of what the browser already does (Tab moves focus, Enter activates a button).
| Key | What it does |
|---|---|
| ←→ | Adjusts the value by step (in RTL, the right arrow decreases it, like the native input). |
| ↑↓ | Same as the horizontal arrows. When vertical, ↑ moves toward the maximum. |
| Home/End | Goes to the minimum or the maximum. With is-range, the start handle stops at the end handle and vice versa. |
| Page Up/Page Down | Jumps several steps, like the native input. With stops (data-ts-slider-values), it moves one stop, or a tenth of the list when there are more than 14. |
| Tab | With is-range, moves through both handles (start, then end). |
Verification
What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.
- axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
- keyboard Key map documented above, checked against the component.
- screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.