Skip to Content
Soundor Components
Components

Slider

A horizontal control for one numeric value.

Use Slider where a horizontal track fits the layout.

import { Slider } from '@soundor/components';
import { parameters } from 'soundor:parameters';

export default function Demo() {
  return <Slider parameter={parameters.mix} width={220} />;
}
slider.tsx, running in the web runtime.Source

Usage

With a parameter

Pass a generated parameter and the control inherits its range, mapping, formatting, parser and reset value. It opens and closes host gestures and records undo history; set history={false} to opt out, or history={{ label: 'Adjust feedback' }} to name the entry.

<Slider parameter={parameters.mix} />

Without a parameter

Pass value and onChange (or defaultValue) with the range you need. A controlled control should update value in response to onChange.

const [mix, setMix] = useState(0.5);

<Slider label="Mix" value={mix} onChange={setMix} />;

The default drag is absolute with the track's ends inset; set dragMode="relative" to move from where the drag started.

Keyboard and accessibility

← → ↑ ↓ change the value by 1% of the range, Page Up and Page Down by 10%, and Home and End go to the minimum and maximum. Shift makes any of them ten times finer. A press on the thumb grabs it where it is, and a press elsewhere jumps it to the pointer (hold Shift to grab it where it is from anywhere). A double-click on the thumb or an Alt-click (Option-click on a Mac) anywhere resets the value, as do Delete and Backspace, and Esc cancels a drag. A screen reader hears the label and formatted value, and can increment, decrement, set or reset it. See Keyboard and accessibility.

Props

See Mixed values for editing multiple items.

Slider props

Prop

Type

Range props

Prop

Type

On this page