Important
This is the documentation for the v2 Release Candidate.
You can install it using the @next tag.
npm i range-slider-element@next
A cross browser customizable and accessible web component.
- Framework agnostic web component (no dependencies)
- Cross browser customizable styling
- Single and multi thumb
- Horizontal and vertical orientations
- Works like a built-in HTML form element (uses ElementInternals)
- Keyboard accessible (use arrow keys)
- Touch friendly
- Follows the ARIA best practices guide on sliders
npm install range-slider-element
Make sure to load the base styles exported via range-slider-element/style.css
.
import 'range-slider-element';
Or via CDN
<link rel="stylesheet" href="https://unpkg.com/range-slider-element@latest/dist/range-slider-element.css">
<script type="module" src="https://unpkg.com/range-slider-element@latest/dist/range-slider-element.js"></script>
HTML
<range-slider min="0" max="100" step="1" value="50"></range-slider>
min
The minimum permitted value. The default is0
.max
The maximum permitted value. The default is100
.step
The stepping interval. The default is1
.value
The value. The default ismin + (max - min) / 2
.dir
Directionality. The default is ltr. Allowed optionsrtl
.orientation
The default is horizontal. Allowed optionsvertical
.
Exposed CSS custom properties scoped within the range-slider
element.
--track-size
- The track size. The default is0.2rem
. Can be overwritten for customization.--thumb-size
- The thumb size. The default is1.2rem
. Can be overwritten for customization.
range-slider {}
range-slider [data-track] {}
range-slider [data-track-fill] {}
range-slider [data-thumb] {}
/* Advanced customization */
range-slider [data-runnable-track] {}
For examples of how to customize the default styling, see the docs.
input
- Pointer move, value changed. Bubbles.change
- Pointer up, key up, value changed. Bubbles.
Browsers without native custom element support require a polyfill.
MIT ยฉ Andrรฉ Ruffert