Slider
A control that allows users to select a value or range from a given range.
Usage
Slider Props
Prop | Type | Default |
---|---|---|
variant | "single" | "range" | - |
value | number | [number, number] | - |
defaultValue | number | [number, number] | - |
min | number | 0 |
max | number | 100 |
step | number | 1 |
label | string | [string, string] | - |
onChange | (value: number | [number, number]) => void | - |
className | string | - |
Examples
Variant
Controlled Usage
A controlled slider that maintains and updates its state through React's useState hook.
Accessibility
The Slider component follows WAI-ARIA guidelines for the Slider Pattern.
ARIA Attributes
The component handles the following ARIA attributes:
aria-label
: Provides an accessible name for the slideraria-valuetext
: Provides a human-readable text alternative for the current valuearia-valuemin
: Set automatically based on themin
proparia-valuemax
: Set automatically based on themax
proparia-valuenow
: Updated automatically as the value changes
Example with Custom ARIA Labels
Screen Reader Considerations
- Each thumb in a range slider has its own accessible label
- Values are announced as they change
- The component supports both mouse and keyboard interactions
- Labels are properly associated with their respective thumbs