Slider
Pick a number within a range by dragging the thumb or stepping with the keyboard: single thumb, dual-thumb range, tick marks and value display.
Basic usage
The first row is a controlled single slider; the second row enables the dual-thumb range mode; the third row shows step for the increment with showInput displaying the current value, plus a disabled slider; the fourth row switches size; the fifth row renders tick marks via marks.
import { useState } from 'react'
import { LhSlider } from '@lh-ui/react'
export default function Demo() {
const [value, setValue] = useState(30)
return <LhSlider value={value} onChange={setValue} />
}
LhSlider Props
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| value | Controlled value (tuple for range) | number | [number, number] | — | — |
| defaultValue | Uncontrolled default value | number | [number, number] | — | min ([min, (min + max) / 2] for range) |
| min | Minimum value | number | — | 0 |
| max | Maximum value | number | — | 100 |
| step | Step increment | number | — | 1 |
| disabled | Whether to disable | boolean | — | false |
| range | Dual-thumb range mode | boolean | — | false |
| showInput | Show current value text | boolean | — | false |
| size | Size | string | small / medium / large | medium |
| marks | Tick marks (key: value, value: label) | Record<number, string> | — | — |
| sx | Shorthand layout props | SxProps | — | — |
LhSlider events
| Event | Description | Callback signature | Vue equivalent |
|---|---|---|---|
| onChange | Value change (per key press; drag commits on pointer up) | (value: number | [number, number]) => void | @update:modelValue / @change |
Each thumb is a role="slider" with aria-valuemin/max/now and a value text (the two thumbs in range mode are labeled "start slider" / "end slider"). Keyboard: arrow keys step by step, PageUp/PageDown take large steps, Home/End jump to the extremes; in range mode a thumb never crosses the other end, keeping the focused thumb and the edited value in sync.
Styles
import '@lh-ui/react/style/slider'