Skip to content

Slider

Slider control for selecting a single value or a range.

Volume
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider {...args} />
Volume
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider label="Volume" value={50} width={320} />
Price range
function ControlledRangeSlider({
value: initialValue = DEFAULT_RANGE_VALUE,
isOptional,
isRequired,
...args
}: ControlledRangeSliderProps): React.JSX.Element {
const [value, setValue] = useState<[number, number]>(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledRangeSlider label="Price range" value={[20, 80]} />
Completion
50
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider
label="Completion"
marks={defaultMarks}
value={50}
valueDisplay="text"
/>
Budget
$250
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider
formatValue={value => `$${value}`}
label="Budget"
max={500}
step={25}
value={250}
valueDisplay="text"
/>
Opacity
60%
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider
formatValue={value => `${value}%`}
label="Opacity"
value={60}
valueDisplay="text"
/>
Brightness
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider label="Brightness" value={40} valueDisplay="none" />
Level
65
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<div style={{height: 220}}>
<ControlledSingleSlider
label="Level"
orientation="vertical"
value={65}
valueDisplay="text"
/>
</div>
Disabled volume
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider isDisabled label="Disabled volume" value={50} />
Volume
90
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider
label="Volume"
status={{
message: 'Volume is above the recommended range.',
type: 'error',
}}
value={90}
valueDisplay="text"
/>
Allowed range
30 - 60
function ControlledRangeSlider({
value: initialValue = DEFAULT_RANGE_VALUE,
isOptional,
isRequired,
...args
}: ControlledRangeSliderProps): React.JSX.Element {
const [value, setValue] = useState<[number, number]>(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledRangeSlider
label="Allowed range"
minStepsBetweenThumbs={2}
step={5}
value={[30, 60]}
valueDisplay="text"
/>
Step 5
45
Step 0.1
0.5
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<VStack gap={6}>
<ControlledSingleSlider
label="Step 5"
step={5}
value={45}
valueDisplay="text"
/>
<ControlledSingleSlider
formatValue={value => value.toFixed(1)}
label="Step 0.1"
max={1}
step={0.1}
value={0.5}
valueDisplay="text"
/>
</VStack>
Temperature
70
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider
label="Temperature"
marks={[
{label: '-50F', value: -50},
{label: '0F', value: 0},
{label: '100F', value: 100},
{label: '200F', value: 200},
]}
max={200}
min={-50}
step={10}
value={70}
valueDisplay="text"
/>
Volume
function ControlledSingleSlider({
value: initialValue = 50,
isOptional,
isRequired,
...args
}: ControlledSingleSliderProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<Slider
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledSingleSlider {...args} />

Slider control for selecting a single value or a range.

When isOptional: false, isRequired: false

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the field root.
descriptionstringSupporting text displayed below the label.
formatValue(value: number) => stringCustom value formatter used for visible value text, tooltip content, and aria-valuetext.
htmlNamestringHTML name attribute for native form submission. Range sliders submit one entry per value.
isDisabledbooleanfalseWhether the slider is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*stringField label.
labelTooltipstringTooltip content shown next to the label.
marksSliderMark[]Tick marks rendered along the track.
maxnumber100Maximum value.
minnumber0Minimum value.
orientation"horizontal" | "vertical"'horizontal'Slider orientation.
refRef<HTMLDivElement>Ref forwarded to the field root.
statusInputStatusValidation status displayed below the slider.
stepnumber1Step increment.
styleCSSPropertiesInline styles applied to the field root.
valueDisplay"none" | "text" | "tooltip"'tooltip'How to display the current value.
widthSizeValueSlider width. Numbers are pixels, strings are used as-is.
isOptionalfalse
isRequiredfalse
minStepsBetweenThumbsnumber0Minimum number of steps between range thumbs.
onChange*(value: [number, number]) => voidCalled when the range changes during pointer or keyboard interaction.
onChangeEnd(value: [number, number]) => voidCalled when pointer or keyboard interaction commits a range.
value*[number, number]Current range.

When isOptional: true, isRequired: false

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the field root.
descriptionstringSupporting text displayed below the label.
formatValue(value: number) => stringCustom value formatter used for visible value text, tooltip content, and aria-valuetext.
htmlNamestringHTML name attribute for native form submission. Range sliders submit one entry per value.
isDisabledbooleanfalseWhether the slider is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*stringField label.
labelTooltipstringTooltip content shown next to the label.
marksSliderMark[]Tick marks rendered along the track.
maxnumber100Maximum value.
minnumber0Minimum value.
orientation"horizontal" | "vertical"'horizontal'Slider orientation.
refRef<HTMLDivElement>Ref forwarded to the field root.
statusInputStatusValidation status displayed below the slider.
stepnumber1Step increment.
styleCSSPropertiesInline styles applied to the field root.
valueDisplay"none" | "text" | "tooltip"'tooltip'How to display the current value.
widthSizeValueSlider width. Numbers are pixels, strings are used as-is.
isOptional*true
isRequiredfalse
minStepsBetweenThumbsnumber0Minimum number of steps between range thumbs.
onChange*(value: [number, number]) => voidCalled when the range changes during pointer or keyboard interaction.
onChangeEnd(value: [number, number]) => voidCalled when pointer or keyboard interaction commits a range.
value*[number, number]Current range.

When isOptional: false, isRequired: true

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the field root.
descriptionstringSupporting text displayed below the label.
formatValue(value: number) => stringCustom value formatter used for visible value text, tooltip content, and aria-valuetext.
htmlNamestringHTML name attribute for native form submission. Range sliders submit one entry per value.
isDisabledbooleanfalseWhether the slider is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*stringField label.
labelTooltipstringTooltip content shown next to the label.
marksSliderMark[]Tick marks rendered along the track.
maxnumber100Maximum value.
minnumber0Minimum value.
orientation"horizontal" | "vertical"'horizontal'Slider orientation.
refRef<HTMLDivElement>Ref forwarded to the field root.
statusInputStatusValidation status displayed below the slider.
stepnumber1Step increment.
styleCSSPropertiesInline styles applied to the field root.
valueDisplay"none" | "text" | "tooltip"'tooltip'How to display the current value.
widthSizeValueSlider width. Numbers are pixels, strings are used as-is.
isOptionalfalse
isRequired*true
minStepsBetweenThumbsnumber0Minimum number of steps between range thumbs.
onChange*(value: [number, number]) => voidCalled when the range changes during pointer or keyboard interaction.
onChangeEnd(value: [number, number]) => voidCalled when pointer or keyboard interaction commits a range.
value*[number, number]Current range.

When isOptional: false, isRequired: false

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the field root.
descriptionstringSupporting text displayed below the label.
formatValue(value: number) => stringCustom value formatter used for visible value text, tooltip content, and aria-valuetext.
htmlNamestringHTML name attribute for native form submission. Range sliders submit one entry per value.
isDisabledbooleanfalseWhether the slider is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*stringField label.
labelTooltipstringTooltip content shown next to the label.
marksSliderMark[]Tick marks rendered along the track.
maxnumber100Maximum value.
minnumber0Minimum value.
orientation"horizontal" | "vertical"'horizontal'Slider orientation.
refRef<HTMLDivElement>Ref forwarded to the field root.
statusInputStatusValidation status displayed below the slider.
stepnumber1Step increment.
styleCSSPropertiesInline styles applied to the field root.
valueDisplay"none" | "text" | "tooltip"'tooltip'How to display the current value.
widthSizeValueSlider width. Numbers are pixels, strings are used as-is.
isOptionalfalse
isRequiredfalse
onChange*(value: number) => voidCalled when the value changes during pointer or keyboard interaction.
onChangeEnd(value: number) => voidCalled when pointer or keyboard interaction commits a value.
value*numberCurrent value.

When isOptional: true, isRequired: false

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the field root.
descriptionstringSupporting text displayed below the label.
formatValue(value: number) => stringCustom value formatter used for visible value text, tooltip content, and aria-valuetext.
htmlNamestringHTML name attribute for native form submission. Range sliders submit one entry per value.
isDisabledbooleanfalseWhether the slider is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*stringField label.
labelTooltipstringTooltip content shown next to the label.
marksSliderMark[]Tick marks rendered along the track.
maxnumber100Maximum value.
minnumber0Minimum value.
orientation"horizontal" | "vertical"'horizontal'Slider orientation.
refRef<HTMLDivElement>Ref forwarded to the field root.
statusInputStatusValidation status displayed below the slider.
stepnumber1Step increment.
styleCSSPropertiesInline styles applied to the field root.
valueDisplay"none" | "text" | "tooltip"'tooltip'How to display the current value.
widthSizeValueSlider width. Numbers are pixels, strings are used as-is.
isOptional*true
isRequiredfalse
onChange*(value: number) => voidCalled when the value changes during pointer or keyboard interaction.
onChangeEnd(value: number) => voidCalled when pointer or keyboard interaction commits a value.
value*numberCurrent value.

When isOptional: false, isRequired: true

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the field root.
descriptionstringSupporting text displayed below the label.
formatValue(value: number) => stringCustom value formatter used for visible value text, tooltip content, and aria-valuetext.
htmlNamestringHTML name attribute for native form submission. Range sliders submit one entry per value.
isDisabledbooleanfalseWhether the slider is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*stringField label.
labelTooltipstringTooltip content shown next to the label.
marksSliderMark[]Tick marks rendered along the track.
maxnumber100Maximum value.
minnumber0Minimum value.
orientation"horizontal" | "vertical"'horizontal'Slider orientation.
refRef<HTMLDivElement>Ref forwarded to the field root.
statusInputStatusValidation status displayed below the slider.
stepnumber1Step increment.
styleCSSPropertiesInline styles applied to the field root.
valueDisplay"none" | "text" | "tooltip"'tooltip'How to display the current value.
widthSizeValueSlider width. Numbers are pixels, strings are used as-is.
isOptionalfalse
isRequired*true
onChange*(value: number) => voidCalled when the value changes during pointer or keyboard interaction.
onChangeEnd(value: number) => voidCalled when pointer or keyboard interaction commits a value.
value*numberCurrent value.