Skip to content
+

Slider

Sliders allow users to make selections from a range of values.

Sliders reflect a range of values along a bar, from which users may select a single value. They are ideal for adjusting settings such as volume, brightness, or applying image filters.

Continuous sliders

Continuous sliders allow users to select a value along a subjective range.

Press Enter to start editing

Sizes

For smaller slider, use the prop size="small".

Press Enter to start editing

Discrete sliders

Discrete sliders can be adjusted to a specific value by referencing its value indicator. You can generate a mark for each step with marks={true}.

Press Enter to start editing

Small steps

You can change the default step increment. Make sure to adjust the shiftStep prop (the granularity with which the slider can step when using Page Up/Down or Shift + Arrow Up/Down) to a value divadable with the step.

Press Enter to start editing

Custom marks

You can have custom marks by providing a rich array to the marks prop.

Press Enter to start editing

Restricted values

You can restrict the selectable values to those provided with the marks prop with step={null}.

Press Enter to start editing

Label always visible

You can force the thumb label to be always visible with valueLabelDisplay="on".

Press Enter to start editing

Range slider

The slider can be used to set the start and end of a range by supplying an array of values to the value prop.

Press Enter to start editing

Minimum distance

You can enforce a minimum distance between values in the onChange event handler. By default, when you move the pointer over a thumb while dragging another thumb, the active thumb will swap to the hovered thumb. You can disable this behavior with the disableSwap prop. If you want the range to shift when reaching minimum distance, you can utilize the activeThumb parameter in onChange.

Press Enter to start editing

Slider with input field

In this example, an input allows a discrete value to be set.

Volume

Color

Press Enter to start editing

Customization

Here are some examples of customizing the component. You can learn more about this in the overrides documentation page.

iOS

pretto.fr

Tooltip value label

Airbnb

Music player

can't win - Chilling Sunday
Jun Pulse

คนเก่าเขาทำไว้ดี (Can't win)

Chilling Sunday — คนเก่าเขาทำไว้ดี

0:32

-2:48

Vertical sliders

WARNING: Chrome, Safari and newer Edge versions that is any browser based on WebKit exposes <Slider orientation="vertical" /> as horizontal (chromium issue #1158217). By applying -webkit-appearance: slider-vertical; the slider is exposed as vertical.

However, by applying -webkit-appearance: slider-vertical; keyboard navigation for horizontal keys (Arrow Left, Arrow Right) is reversed (chromium issue #1162640). Usually, up and right should increase and left and down should decrease the value. If you apply -webkit-appearance you could prevent keyboard navigation for horizontal arrow keys for a truly vertical slider. This might be less confusing to users compared to a change in direction.

Press Enter to start editing

Marks placement

You can customize your slider by adding and repositioning marks for minimum and maximum values.

0 min

100 max

Track

The track shows the range available for user selection.

Removed track

The track can be turned off with track={false}.

Removed track

Removed track range slider

Inverted track

The track can be inverted with track="inverted".

Inverted track

Inverted track range

Non-linear scale

You can use the scale prop to represent the value on a different scale.

In the following demo, the value x represents the value 2^x. Increasing x by one increases the represented value by factor 2.

Storage: 1 MB

Press Enter to start editing

Accessibility

(WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb/)

The component handles most of the work necessary to make it accessible. However, you need to make sure that:

  • Each thumb has a user-friendly label (aria-label, aria-labelledby or getAriaLabel prop).
  • Each thumb has a user-friendly text for its current value. This is not required if the value matches the semantics of the label. You can change the name with the getAriaValueText or aria-valuetext prop.

Limitations

IE 11

The slider's value label is not centered in IE 11. The alignment is not handled to make customizations easier with the latest browsers. You can solve the issue with:

.MuiSlider-valueLabel {
  left: calc(-50% - 4px);
}

Unstyled

Use the Base UI Slider for complete ownership of the component's design, with no Material UI or Joy UI styles to override. This unstyled version of the component is the ideal choice for heavy customization with a smaller bundle size.

API

See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.