Free and open-source React slider components built for modern applications and websites. These sliders are built using React Aria and styled with Tailwind CSS.
Installation
You can add this slider component using our CLI or manually:
npx untitledui@latest add slider
Slider examples
Below are examples and variations of this slider component:
API reference
Slider
Import Slider from @/components/base/slider/slider. Renders React Aria’s Slider — all of its props are supported.
Props from React Aria (20)
Also accepts the global HTML attributes (dir, lang, hidden, inert, translate), all standard React DOM event handlers.
FAQs
Please refer to our frequently asked questions page for more.
Pass an array to defaultValue or value, such as defaultValue={[0, 25]}. The slider renders one thumb per value and fills the track between them. Pass a single number, such as defaultValue={50}, for a one-thumb slider that fills from the start.
Set labelPosition to "bottom" to show the value below each thumb, or "top-floating" to show it in a tooltip above each thumb. The default, "default", hides the value label.
The built-in label divides the thumb value by 100 before formatting it, and shows a whole percentage by default, so it only reads correctly for a 0 to 100 range. Custom formatOptions also receive the divided value. For other ranges or units, pass labelFormatter, which receives the raw thumb value and returns a string, for example labelFormatter={(value) => "$" + value}.
Use React Aria's minValue, maxValue and step props. minValue defaults to 0 and maxValue defaults to 100.
Pass value and onChange for controlled state, or defaultValue for uncontrolled state. For a range slider, both are arrays. Use onChangeEnd if you only need the final value after the user stops dragging.
Yes. Each thumb is focusable with Tab and shows a focus ring. The arrow keys move the focused thumb by step, Page Up and Page Down move it in larger increments, and Home and End jump to its minimum or maximum. In a range slider, a thumb can't move past the other thumb.