Slider
Last updated: 2.0.0 (18/01/2024)
Sliders are a more visually-focused alternative to the Number input. By default, the slider will include a number input without controls positioned directly to its right.
Usage
Min, max & step
Sliders will default to a minimum of 0
, maximum of 100
and step of 1
. This can be modified using the min
, max
and step
props, respectively:
Moving or hiding the manual input
By default, a "manual" number input will be positioned directly to the right of the slider. This can be moved or hidden entirely using the manualInputPosition
and includeManualInput
props:
Complex handle
By passing true
into the showValue
prop, the value of the slider will be displayed on the slider handle itself. This is especially recommended if you have hidden the manual input.
Props
Extends GenericInputProps<number>
and SliderEventProps
.
min
number
The minimum value of this input. 0
by default.
max
number
The maximum value of this input. 100
by default.
step
number
The step value of this input. 1
by default.
showValue
boolean
Whether to show this slider's value on the thumb. false
by default.
invert
invert
Whether to invert the direction of the slider. false
by default.
includeManualInput
boolean
Whether to include a manual input with this slider. true
by default.
manualInputPosition
"left" | "right"
The position of this manual input, if shown. "right"
by default.
SliderEventProps
Accepts T = number
as an optional type identifier.
onAfterChange
(value: T, thumbIndex: number) => void
Callback fired after a thumb has been moved.
onBeforeChange
(value: T, thumbIndex: number) => void
Callback fired before a thumb is starting to move.
onChange
(value: T, thumbIndex: number) => void
Callback fired when the value of this input changes.
onSliderClick
(value: number) => void
Callback fired when any part of the slider is clicked.
SliderTrackProps
Extends StyledFlexProps
.
state (required)
{ index: number, value: number }
(internal use)
highlight
boolean
Whether to highlight this track. false
by default.
SliderThumbProps
Extends StyledFlexProps
.
state (required)
{ index: number, valueNow: number, value: number }
(internal use)
showValue
boolean
Whether to show the value of this slider. false
by default.
Last updated
Was this helpful?