Skip to content

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

html

Price range

⁨20 USD⁩ – ⁨80 USD⁩
0 100
html

Vertical

60%
html

Read-only

65%
html

Uneven stops

25 seats
5 seats 250 seats
html

Text per stop

25 seats
html

Class reference

Every value of each modifier, with its HTML ready to copy.

Size

Control thickness: sm, md, or lg.

40
40
40
html

States

is-disabled blocks dragging; is-readonly can be focused and read but doesn’t change.

html

Range

is-range adds two handles that can’t cross; the span between them is filled.

html

Orientation

is-vertical puts the minimum at the bottom.

html

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-values lists 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-format or data-ts-slider-texts). The screen reader says “6 px, Suave,” not a position.
  • Pick a step that doesn’t frustrate—neither too fine nor too coarse.
  • Save or fetch data when the value is committed. ts:commit fires on release; ts:change fires on every movement.
  • Use aria-readonly="true" on the input, not disabled, 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.

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-slider
  • data-ts-slider-format
  • data-ts-slider-rail
  • data-ts-slider-range
  • data-ts-slider-value
  • data-ts-slider-values
  • data-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-sliderThe component’s root.
data-ts-slider-range, data-ts-slider-railTwo 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-valuesThe 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-valuetextWhat 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-textsOne 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-ticksA <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-formatThe 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-verticalMakes it vertical.
ts:changeFires on every move and is cancelable (the handle snaps back). Carries detail.value (a number, or [inicio, fin] with range) and index.
ts:commitFires 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 exposes aria-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-valuenow and the stop’s text in aria-valuetext (always, even with no format; data-ts-slider-valuetexts or data-ts-slider-valuetext set it apart from the visible text). The screen reader says “6 px, Soft,” not “position 3.” The stop ticks (slider-ticks) are aria-hidden.
  • With no visible label, the name comes from aria-label on the input. With a visible label, the label wins.
  • With is-range, it’s a role="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’s aria-valuemax is the end handle’s value, and the end handle’s aria-valuemin is 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-readonly exposes aria-readonly="true". The handle can be focused and read, but neither the keyboard nor the pointer changes it. It doesn’t use disabled, so the value is still submitted with the form.
  • is-vertical exposes aria-orientation="vertical". The minimum is at the bottom.
  • With forced-colors: active, the filled range paints with Highlight and the rest with GrayText, 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/EndGoes to the minimum or the maximum. With is-range, the start handle stops at the end handle and vice versa.
Page Up/Page DownJumps 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.
TabWith 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.