Skip to main content

Slider

An input where the user selects a value from within a given range.

Anatomy​

import { Slider } from '@streamelements/frontend-ui';

<Slider.Root max={4}>
<Slider.Track>
<Slider.NumericSegments />
<Slider.Range />
</Slider.Track>
<Slider.ThumbsContainer>
<Slider.Thumb />
</Slider.ThumbsContainer>
<Slider.ValueSegments />
</Slider.Root>

Basic example​

Idle 0/4

Hover 0/4

Focus 1/4

Idle 3/4

Disabled 3/4

import { Slider } from '@streamelements/frontend-ui';

...

<Slider.Root max={4}>
<Slider.ThumbsContainer>
<Slider.Thumb />
</Slider.ThumbsContainer>
</Slider.Root>

Segmented numeric​

This component adds a dot on each step of the component.

Idle 0/4

Hover 0/4

Focus 1/4

Idle 3/4

Disabled 3/4

import { Slider } from '@streamelements/frontend-ui';

<Slider.Root max={[4]}>
<Slider.Track>
<Slider.NumericSegments />
<Slider.Range />
</Slider.Track>
<Slider.ThumbsContainer>
<Slider.Thumb />
</Slider.ThumbsContainer>
<Slider.ValueSegments />
</Slider.Root>

Segmented values​

This component adds a label underneath every step of the component. If you don't pass labels prop to it, the index of each step will be shown.

Idle 0/4

ValueValueValueValueValue

Hover 0/4

ValueValueValueValueValue

Focus 1/4

ValueValueValueValueValue

Idle 3/4

ValueValueValueValueValue

Disabled 3/4

ValueValueValueValueValue

Segment type

0100020003000
import { Slider } from '@streamelements/frontend-ui';

<Slider.Root max={[4]}>
<Slider.Track>
<Slider.NumericSegments />
<Slider.Range />
</Slider.Track>
<Slider.ThumbsContainer>
<Slider.Thumb />
</Slider.ThumbsContainer>
<Slider.ValueSegments />
</Slider.Root>

API​

Root​

Name

Type

Default value

Description

asChildboolean–
Change the component to the HTML tag or custom component of the only child. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.
defaultValuenumber[]–
The initial value of the component. Use when you do not need to control the state of the Slider.
valuenumber[]–
The controlled value of the slider.
Must be used in conjunction with onValueChange
namestring–
The name of the switch. Submitted with its parent form.
disabledboolean–
When true, prevents user interaction with the component.
orientationstringhorizontal
Not implemented
dirstringltr
Not implemented
minnumber0
The minimum value for the range
maxnumber100
The maximum value for the range
stepnumber1
The step interval
onValueChangeFunction–
Event handler when the value changes.
minStepsBetweenThumbsnumber0
The minimum permitted steps between multiple thumbs

ThumbsContainer​

Contains the thumbs.

Thumb​

Name

Type

Default value

Description

asChildboolean–
Change the component to the HTML tag or custom component of the only child. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.
labelstring–
Custom text to display on the tooltip of the Thumb
inputPropsReact.HTMLProps<HTMLInputElement>–
Props for the input representation of the thumb

NumericSegments​

Name

Type

Default value

Description

asChildboolean–
Change the component to the HTML tag or custom component of the only child. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.
variantdot | dash | Functiondot
Defines the way each step of the slider will look. An option to pass in a function (index: number) => Type, to define different look per index

ValueSegments​

Name

Type

Default value

Description

asChildboolean–
Change the component to the HTML tag or custom component of the only child. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.
labelsstring[]Array((max / step) + 1) - min)
The text value for the label of each step

Examples​

Multi-thumb​

Providing multiple entries in defaultValue or value, renders the same amount of thumbs to control the values.

<Slider.Root min={1} defaultValue={[2, 4]} max={5}>
<Slider.Track>
<Slider.Range/>
</Slider.Track>
<Slider.ThumbsContainer>
<Slider.Thumb />
<Slider.Thumb />
</Slider.ThumbsContainer>
<Slider.NumericSegments />
</Slider.Root>

Prevent thumb overlap​

Setting minStepsBetweenThumbs to 1 prevents the thumbs from overlapping.

<Slider.Root min={1} defaultValue={[2, 4]} max={5} minStepsBetweenThumbs={1}>
<Slider.Track>
<Slider.Range/>
</Slider.Track>
<Slider.ThumbsContainer>
<Slider.Thumb />
<Slider.Thumb />
</Slider.ThumbsContainer>
<Slider.NumericSegments />
</Slider.Root>