Introducing PrimeReact v11-alpha 🎉Discover Now

Slider

Slider is a component to provide input with a drag handle.

Let it happen
Tame Impala
2:083:45
preview

Installation#

npx shadcn@latest add @primereact/slider

Usage#

import { Slider } from '@/components/ui/slider';
<Slider defaultValue={50} />

Examples#

Basic#

basic-demo

Step#

Size of each movement is defined with the step property.

step-demo

Range#

Slider provides two handles to define two values. In range mode, value should be an array instead of a single value.

range-demo

Thumbs Distance#

thumbs-distance-demo

Vertical#

Default layout of slider is horizontal, use orientation property for the alternative vertical mode.

Bass
Mid
Treble
vertical-demo

Disabled#

When disabled is present, the element cannot be edited and focused.

disabled-demo

Controlled#

controlled-demo

Value Change#

onValueChange: 50
onValueChangeEnd: 50
value-change-demo

Filter#

Image filter implementation using multiple sliders.

user header
filter-demo

Accessibility#

Screen Reader#

Slider element component uses slider role on the handle in addition to the aria-orientation, aria-valuemin, aria-valuemax and aria-valuenow attributes. Value to describe the component can be defined using aria-labelledby and aria-label props.

Keyboard Support#

KeyFunction
tabMoves focus to the slider.
left arrow / up arrowDecrements the value.
right arrow / down arrowIncrements the value.
homeSet the minimum value.
endSet the maximum value.
page upIncrements the value by 10 steps.
page downDecrements the value by 10 steps.