Skip to main content

Slider

Examples

Check out the Usage section for details about how to design a Slider properly, and the different configuration options we provide.

Basic example

You can give a user the means to select a numeric value via sliding a handle across a bar.

<Slider
label="Slider"
secondaryLabel="Choose Value"
/>

Min and max example

You can indicate a minimum and maximum value a user can select using the component.

<Slider
label="Slider"
secondaryLabel="Choose Value"
min={5}
max={10}
/>

Range example

You can add the range property to let a user select a range of values. This adds a second handle for the user to move.

<Slider
label="Select Range"
secondaryLabel="Choose Values"
range
/>

Minimum range example

You can limit the minimum size of the range a user can select. If the user tries to select a smaller range, the other handle moves too, if possible, to maintain the minimum distance between the two points.

<Slider
label="Select Range"
secondaryLabel="Choose Values"
range
minimumRange={10}
/>

OnChange example

You can trigger a function to run when the value is changed.

<Slider
label="Select Value"
secondaryLabel="Choose Value"
onChange={(event, value) => console.log('The value chosen is', value)}
/>

OnChange range example

When you set the slider to range mode, the value emitted will be an array of [minimum selected, maximum selected].

<Slider
label="Select Range"
secondaryLabel="Choose Values"
onChange={(event, value) => console.log('The values chosen are', value)}
/>