Forms
Slider
Choose a value in a range by dragging, clicking the track or using the keyboard. Values are formatted for the visible output and for screen readers.
import { Slider } from '@reactloom/ui';Examples
Basic
Controlled, percent-formatted, small and disabled.
import { Slider, Stack } from '@reactloom/ui';
import { useState } from 'react';
export default function Example() {
const [volume, setVolume] = useState(40);
return (
<Stack gap="6" style={{ width: '100%', maxWidth: 360 }}>
<Slider label="Volume" value={volume} onValueChange={setVolume} />
<Slider label="Opacity" defaultValue={0.6} minValue={0} maxValue={1} step={0.05} formatOptions={{ style: 'percent' }} size="sm" />
<Slider label="Disabled" defaultValue={30} disabled />
</Stack>
);
}API reference
| Prop | Type | Default |
|---|---|---|
label | ReactNode | — |
aria-labelWhen there is no visible label. | string | — |
value / defaultValue | number | — |
onValueChangeFires continuously while dragging. | (value: number) => void | — |
onValueCommitFires once when the drag ends. | (value: number) => void | — |
minValue · maxValue · step | number | 0 · 100 · 1 |
formatOptionsAlso used for aria-valuetext. | Intl.NumberFormatOptions | — |
showValue | boolean | true |
nameNative form submission. | string | — |
disabled | boolean | false |
size | 'sm' | 'md' | 'md' |
Accessibility
- Each thumb is a native range input, so assistive technology and forms work without scripting tricks.
- aria-valuetext uses the formatted value (e.g. “40%”, “$200”).
- Arrow keys are mirrored in right-to-left layouts.
| Key | Action |
|---|---|
| ← / → · ↑ / ↓ | Decrease / increase by step |
| Page Up / Page Down | Larger step |
| Home / End | Minimum / maximum |
Usage guidelines
Do
- Show the value when precision matters.
- Use onValueCommit for expensive updates (network, heavy re-render).
Don’t
- Don’t use a slider when people need an exact value — use NumberInput (or pair them).