# Slider
[Sliders](https://material.io/components/sliders/) allow users to make
selections from a range of values.
The MDC Slider implementation supports both single point sliders (one thumb)
and range sliders (two thumbs). It is backed by the browser
`` element, is fully accessible, and is RTL-aware.
**Contents**
* [Using sliders](#using-sliders)
* [Sliders](#sliders)
* [Other variants](#other-variants)
* [Additional information](#additional-information)
* [API](#api)
## Using sliders
### Installing sliders
```
npm install @material/slider
```
### Styles
```scss
@use "@material/slider/styles";
```
### JavaScript instantiation
```js
import {MDCSlider} from '@material/slider';
const slider = new MDCSlider(document.querySelector('.mdc-slider'));
```
**Note**: See [Importing the JS component](../../docs/importing-js.md) for more
information on how to import JavaScript.
### Making sliders accessible
Sliders are backed by an `` element, meaning that they are fully
accessible. Unlike the [ARIA-based slider](https://www.w3.org/TR/wai-aria-practices/#slider),
MDC sliders are adjustable using touch-based assistive technologies such as
TalkBack on Android.
Per the spec, ensure that the following attributes are added to the
`input` element(s):
* `value`: Value representing the current value.
* `min`: Value representing the minimum allowed value.
* `max`: Value representing the maximum allowed value.
* `aria-label` or `aria-labelledby`: Accessible label for the slider.
If the value is not user-friendly (e.g. a number to
represent the day of the week), also set the following:
* `aria-valuetext`: Set this input attribute to a string that makes the slider
value understandable, e.g. 'Monday'.
* Add a function to map the slider value to `aria-valuetext` via the
`MDCSlider#setValueToAriaValueTextFn` method.
## Sliders
There are two types of sliders:
1. [Continuous slider](#continuous-slider)
1. [Discrete slider](#discrete-slider)
### Continuous slider
Continuous sliders allow users to make meaningful selections that don’t require
a specific value.
Note: The step size for value quantization is, by default, 1. To specify
a custom step size, provide a value for the `step` attribute on the `input`
element.
```html
```html
```
### Discrete slider
Discrete sliders display a numeric value label upon pressing the thumb, which
allows a user to select an exact value.
To create a discrete slider, add the following:
* `mdc-slider--discrete` class on the root element.
* Value indicator element (`mdc-slider__value-indicator-container`), as shown
below.
```html
```
#### Discrete slider with tick marks
Discrete sliders can optionally display tick marks. Tick marks represent
predetermined values to which the user can move the slider.
To add tick marks to a discrete slider, add the following:
* `mdc-slider--tick-marks` class on the root element
* `mdc-slider__tick-marks` element as a child of the `mdc-slider__track`
element
* `mdc-slider__tick-mark--active` and `mdc-slider__tick-mark--inactive`
elements as children of the `mdc-slider__tick-marks` element
```html
```
#### Discrete range slider
```html
```
## Other variants
### Disabled slider
To disable a slider, add the following:
* `mdc-slider--disabled` class on the root element
* `disabled` attribute on the input element
```html
```
## Additional information
### Initialization with custom ranges and values
When `MDCSlider` is initialized, it reads the input element's `min`,
`max`, and `value` attributes if present, using them to set
the component's internal `min`, `max`, and `value` properties.
Use these attributes to initialize the slider with a custom range and values,
as shown below:
```html
```
### Setting slider position before component initialization
When `MDCSlider` is initialized, it updates the slider track and thumb
positions based on the internal value(s). To set the correct track and thumb
positions before component initialization, mark up the DOM as follows:
- Calculate `rangePercentDecimal`, the active track range as a percentage of
the entire track, i.e. `(valueEnd - valueStart) / (max - min)`.
Set `transform:scaleX(