Slider
Picks a number inside a range by dragging a thumb or using the keyboard.
Selector: mui-slider
import { Slider } from '@mushilu-san/ui/forms';Loading example…
Overview
role="slider" thumb with aria-valuemin, aria-valuemax and aria-valuenow. The value is a two-way value model, and min, max and step set the range.
When to use
Choosing a value in a range where the exact number matters less than the rough size, such as volume or price range. Adjusting a setting that the user can see change live.
When not to use
An exact number that the user must type. Use an input with type number. Use Input instead.
Guidelines
Do
Show the current value next to the slider. Set a stepthat matches the precision the user needs.
Don't
Do not use a slider when the user needs an exact value. Do not hide the thumb label in a way that removes the value for screen readers.
Accessibility
Roles and attributes
| Element | Role | Notes |
|---|---|---|
thumb | slider | aria-valuemin, aria-valuemax and aria-valuenow. aria-disabled when disabled. |
Keyboard
| Keys | Action |
|---|---|
| ArrowLeftArrowRight, ArrowUpArrowDown | |
| PageUpPageDown | |
| HomeEnd |
Name the slider with the labelinput. It sets the accessible name of the thumb.
API
Slider
| Name | Type | Default | Description |
|---|---|---|---|
min | number | 0 | Lowest value on the slider. Default `0`. |
max | number | 100 | Highest value on the slider. Default `100`. |
step | number | 1 | Distance between allowed values. Default `1`. |
disabled | boolean | false | Disables the slider. Keyboard and pointer input are ignored. Accepts attribute presence, e.g. <… disabled>. |
label | string | undefined | — | Accessible name for the thumb. Set it, since `aria-label` on the host does not reach the thumb (#729). |
| Name | Type | Default | Description |
|---|---|---|---|
value | number | 0 | Current value. Two-way bindable with `[(value)]`. |
CSS parts
::part(fill)::part(root)::part(thumb)::part(track)
Tokens
--mui-color-primary--mui-color-border--mui-color-focus-ring--mui-touch-target