humanonlyweb/ui

Slider

Pick a number, or a range, by dragging or with the keyboard.

Markdown

Examples

Basic

Volume
Copy code

Range

Bind a [start, end] array for two thumbs. commit fires when a drag ends, for anything expensive.

Price

$200 – $800

Copy code

Vertical

Bass
Treble
Copy code

API

PropTypeDefault
min

Lowest value.

number0
max

Highest value.

number100
step

Arrow-key increment. Values snap to it.

number1
largeStep

PageUp/PageDown increment. Defaults to ten steps.

number—
orientation

Layout hook, exposed as data-orientation and aria-orientation.

"horizontal" | "vertical""horizontal"
disabled

Disables the slider.

booleanfalse
label

Visible label, which names the thumb(s).

string—
thumbLabels

Accessible names for the two thumbs of a range. Default to rangeStart / rangeEnd.

[string, string]—
formatValue

Text for aria-valuetext, e.g. (v) => \${v}%\``.

((value: number) => string)—
name

Form field name; renders a hidden input per value.

string—
modelValue

A number, or [start, end] for a range. Empty starts at min.

T—
EventPayload
commit

A drag ended, or a key changed the value. Use it for expensive work.

[value: T]
update:modelValue

v-model:modelValue update.

[value: T | undefined]
SlotProps
thumb

Thumb content, e.g. a value bubble.

{ value: number; index: number; }

Styling

The range and thumbs are placed with --ui-slider-start, --ui-slider-end and --ui-slider-value (percentages).

Parts
sliderslider-labelslider-controlslider-trackslider-rangeslider-thumb
States
data-orientationdata-slider-disableddata-slider-thumb

Keyboard

KeysAction
← / →, ↓ / ↑One step
Page Up / Page DownlargeStep (ten steps by default)
Home / EndMinimum / maximum

Accessibility

  • Each thumb is named by label; a range's thumbs also get thumb-labels (“Minimum”, “Maximum”).
  • Use format-value so screen readers hear units, e.g. “60%”.
  • In right-to-left layouts, ← / → follow the visual direction.