Contents

Components

Slider

Pick a value along a range by dragging a thumb or pressing keys. The base of the scrubber and the volume control.

Sound effects
Props
step
import { Slider } from "@sideby/ui/slider";

<span id="sound-label">Sound effects</span>
<Slider
  type="single"
  bind:value
  max={100}
  fill="neutral"
  thumbProps={{ "aria-labelledby": "sound-label", "aria-valuetext": `${value} percent` }}
/>

When to use it

A slider suits a value where the rough position matters more than the exact number: how loud, how far in. If the person needs an exact number, give them an input. If there are only a few choices, use a toggle group.

For seeking a video, use the Scrubber, which wraps this slider with spoken time, a buffered range and seeks that fire once per release.

Fill

The range is the accent only when it shows played progress. Any other value, such as volume, uses the neutral fill, so the accent stays reserved for what has played. Either way, the thumb’s control edge is what holds 3:1 against the page.

Accent and neutral
import { Slider } from "@sideby/ui/slider";

<!-- Played progress: the accent run -->
<Slider type="single" value={40} max={100} thumbProps={{ "aria-label": "Progress" }} />

<!-- A setting: neutral -->
<Slider type="single" value={40} max={100} fill="neutral" thumbProps={{ "aria-label": "Volume" }} />

Bind value to read or set it. onValueChange fires on every move and onValueCommit fires once when a drag is released or a key is pressed; use the commit for anything that costs something, such as a seek sent to the room. Pass aria-label (or aria-labelledby) and aria-valuetext through thumbProps; they land on the thumb, which is the element with role="slider".

Accessibility

  • The thumb has role="slider" with aria-valuemin, aria-valuemax and aria-valuenow, and Tab moves to it with the ring outline.
  • Left and Down step down by step, Right and Up step up. Home goes to the minimum and End to the maximum.
  • Name it. Give the thumb an aria-label, or point aria-labelledby at a visible label as the demo does.
  • Say the value in words with aria-valuetext when the number alone means nothing: “60 percent”, “12 minutes 4 seconds of 1 hour 32 minutes”.
  • The bar is 28px tall on a mouse and 44px on a touch screen, and the thumb’s hit area reaches past its edge, so it is easy to grab with a thumb.

Copy

Label the value, not the gesture: Sound effects, not “Drag to change sound effects”. Keep the spoken value in plain units, the way a person would say it.