Skip to content

Slider

40
60
2

A single-thumb slider built on a native <input type="range"> — pointer drag, keyboard control and form participation come from the browser.

<script>
import Slider from "@invisible-ui/svelte/Slider.svelte";
</script>

In Elements, the attributes set the value and the range. The format property turns a number into the text the readouts show, and moving the thumb sends a bubbling change event with detail.value:

<ds-slider label="Volume" name="volume" value="40" step="10" show-value></ds-slider>
PropTypeDefaultDescription
valuenumber0
minnumber0
maxnumber100
stepnumber1
orientation"horizontal" | "vertical""horizontal"
disabledbooleanfalse
label *string—Accessible name.
errorstring | undefinedundefinedError message, shown under the track and announced. The input points at it through aria-describedby and takes aria-invalid. The app owns it: a form reset leaves it in place, so the app clears it.
namestring | undefinedundefinedForm field name — the value is submitted under it.
showValuebooleanfalseShow the current value to the side of the track.
showRangebooleanfalseShow the min and max reference values under the ends of the track.
ticksbooleanfalseShow tick marks at each step (only when the count is reasonable).
format(value: number) => string(v) => String(v)Format the displayed value/range (e.g. add a unit).
onValueChange((value: number) => void) | undefinedundefinedCalled when the value changes.
iconSnippet | undefinedundefinedA decorative icon before the track.
0

A non-empty error shows the message under the control with a hazard icon and announces it as an alert. The input points at it through aria-describedby and takes aria-invalid="true". The message is plain text.

<Slider label="Volume" bind:value error={value === 0 ? "Choose a volume above zero." : ""} />

The app owns the message and clears it: a form reset leaves it in place. In Flutter, the validator’s message clears on form reset.

  • Native <input type="range">: the browser provides the slider role, ARIA value, Arrow/Home/End/PageUp-Down control, pointer dragging and form submission.
  • A non-empty error adds aria-invalid="true" and an aria-describedby link to the message on the input.
<Slider value={40} step={5} label="Volume" />

In React, onValueChange reports each move, and the icon prop takes the leading glyph:

<Slider label="Volume" value={volume} showValue icon={<VolumeIcon />} onValueChange={setVolume} />

Themeable via --ds-slider-*.