Slider
Sets a value, or a range, by dragging along a track. Best for approximate amounts where seeing the position matters more than typing an exact number.
Installation
Set up Camaleo once (Installation), then import it. The skin you load styles the track and the thumbs.
import { Slider } from "@camaleo/react";Anatomy
One component that renders the control, the track, the filled indicator and one thumb per value. Every part has a data-slot you can target from CSS.
Examples
Every example is a real file you can copy. They all wear the skin, mode and brand from the bar above.
Range
Pass an array and you get one thumb per value; name each one with getAriaLabel, since "minimum" and "maximum" aren't visible.
With the value shown
Drag it. Show the value next to the label, and pass the same format and locale so screen readers hear "$25,000" instead of "25000".
Steps
step snaps to the values that make sense; largeStep is what Page Up and Page Down jump by.
Range with a minimum gap
minStepsBetweenValues keeps the thumbs apart, here at least two hours between start and end.
Release to save
Save on release
Drag, then let go. onValueCommitted fires once at the end, so you save or fetch once instead of on every pixel.
Shows clinics within this distance of Curitiba, PR.
Inside a Field
FieldLabel names the thumb and FieldDescription explains the scale, with no getAriaLabel needed.
Vertical
orientation="vertical" fits sliders side by side, like an equalizer; getAriaValueText adds the unit, so screen readers say "+4 decibels".
Upgrade to Pro to stream above 720p.
Disabled, with a reason
A locked slider still shows the current value; say what unlocks it right below.
In context
Sliders sit in panels and players. These are whole pieces of UI you can copy, in the skin you picked.
Luiza Prado
1:12
3:32
Price
Display
Your order #48213 ships tomorrow.
Guidelines
People choosing a loan need to see the amount, not guess it from a position.
Where on the bar is $25,000? Nobody can tell.
Volume, brightness, zoom: the effect is the feedback.
Dragging to 1987 out of 90 years is fiddly; use a NumberField or an input.
Props
(i) => ["Mínimo", "Máximo"][i]. Not needed inside a labelled Field.(text) => text + " reais". Defaults to the formatted value.value prop instead.Intl.NumberFormat when formatting the value.
Defaults to the user's runtime locale.min prop serves as the origin for the valid values.
We recommend (max - min) to be evenly divisible by the step.center) or kept inside the track (edge).'push' (default): Thumbs push each other without restoring their previous positions when dragged back.
- 'swap': Thumbs swap places when dragged past each other.
- 'none': Thumbs cannot move past each other; excess movement is ignored.eventDetails.event. The value is also reflected on
eventDetails.event.target.value for form integration.
The eventDetails.reason indicates what triggered the change:
- 'input-change' when the hidden range input emits a change event (for example, via form integration)
- 'track-press' when the control track is pressed
- 'drag' while dragging a thumb
- 'keyboard' for keyboard input
- 'none' when the change is triggered without a specific interactioneventDetails.reason indicates what triggered the commit:
- 'drag' while dragging a thumb
- 'track-press' when the control track is pressed
- 'keyboard' for keyboard input
- 'input-change' when the hidden range input emits a change event (for example, via form integration)
- 'none' when the commit occurs without a specific interactionPass an array as value or defaultValue for a range. Inside a Field, the label and description reach the thumbs, and disabled / name can come from there too.
Styling hooks
Restyle it without forking: target the attributes, or set the tokens on a parent, a skin or the slider itself.
Attributes
Tokens it reads
Color
Shape & size
Type & motion
This component only
Accessibility
- Each thumb is a native range input with role="slider", aria-valuemin, aria-valuemax and aria-valuenow.
- With format and locale, aria-valuetext reads the formatted value, like "R$ 1.200" or "9 hours"; getAriaValueText adds what the number alone doesn't say, like the unit.
- Outside a Field, give every thumb a name with getAriaLabel.
- The control is at least 24 px tall in every skin, which meets the WCAG 2.2 target size.