Forms & Inputs
@hacline/ui/sliderSlider
Adjust single numeric values or ranges with one or more thumbs.
Usage
Drag either endpoint of the range or step incrementally with arrow keys. Each SliderThumb binds to a value by index and exposes its own accessible label.
"use client";
import {
Slider,
SliderControl,
SliderIndicator,
SliderThumb,
SliderTrack,
SliderValue,
} from "@/components/ui/hacline/components/slider";
export const Example = () => (
<Slider
aria-label="Filter price range"
className="max-w-xs"
defaultValue={[20, 75]}
max={100}
minStepsBetweenThumbs={1}
step={5}
>
<SliderValue aria-label="Current price range" />
<SliderControl>
<SliderTrack>
<SliderIndicator />
<SliderThumb aria-label="Minimum price" index={0} />
<SliderThumb aria-label="Maximum price" index={1} />
</SliderTrack>
</SliderControl>
</Slider>
);Vertical Single Value & Percentage
Represent notification volume from 0 to 1 while formatting the readout as a percentage via format.
"use client";
import {
Slider,
SliderControl,
SliderIndicator,
SliderThumb,
SliderTrack,
SliderValue,
} from "@/components/ui/hacline/components/slider";
export const Example = () => (
<Slider
aria-label="Notification sound"
className="w-auto justify-items-center"
defaultValue={0.5}
format={{ style: "percent" }}
max={1}
orientation="vertical"
step={0.05}
>
<SliderValue aria-label="Current notification volume" />
<SliderControl>
<SliderTrack>
<SliderIndicator />
<SliderThumb aria-label="Notification volume" />
</SliderTrack>
</SliderControl>
</Slider>
);Parts
| Part | Description |
|---|---|
SliderControl | Where presses land. A press on the track moves the nearest thumb there. |
SliderIndicator | The filled part of the track: up to a single thumb, or between a range's thumbs. |
SliderThumb | A thumb, with the native range input that takes focus inside it. Its aria-label, aria-labelledby and aria-describedby go to that input. |
SliderTrack | The rail the thumbs move along. Positions are percentages of it. |
SliderValue | The formatted value, a range joined with an en dash. Children replace it. |
Props
Prop
Type