Skip to content

DocsFormsSlider

PT

Forms

Slider

Pick a value on a scale with ticks. Drag, click or use the keyboard, and it snaps to the tick.

data-u="slider"

Example

Installation

Slider ships in the full package, in unslop.css and unslop.js:

curl -fsSL unslop.leallabs.dev/i | sh

A ready-made block that uses slider:

curl -fsSL unslop.leallabs.dev/i | sh -s add wall-models

No build Name-based add is for charts and blocks. Components with JS live in unslop.js, which mounts every data-u on the page by itself.

Props

They go in data-u-props, as JSON.

PropTypeDefaultWhat it does
minnumber0Lowest value.
maxnumber4Highest value.
stepnumber1Step between ticks. Each step gets a tick on the track.
valuenumberminInitial value.
labelstringno defaultName of the track (aria-label).
leftstringno defaultText at the left end.
rightstringno defaultText at the right end.
textsarrayno defaultOne text per position. It becomes the aria-valuetext and goes in the event.

Accessibility and keyboard

State and roles

WhereAttributeWhat it says
trackrole="slider", tabindex="0"The track takes focus.
trackaria-valuemin, aria-valuemax, aria-valuenowBounds and current value.
trackaria-valuetextThe position text (from texts) or the number.

Keyboard

KeyDoes
Right or up arrowgoes up one step
Left or down arrowgoes down one step
Homegoes to the minimum
Endgoes to the maximum

Events and API

EventdetailWhen
u:change{ value, text }When the value changes, by drag, click or keyboard.

Every event bubbles up the page. Listen on the element itself: el.addEventListener("u:change", (e) => e.detail).

el._u.value reads the current value.

Type to search. Arrows pick, Enter opens.