JSFiddle - React, Tailwind, and code Playground
HTML
<input type="range" multiple min="0" step="1" max="10" data-values="1 9">
SCSS
$multiRangeHeight: 2em;
input[type="range"][multiple] {
display: block;
height: $multiRangeHeight;
margin: 0;
pointer-events: none;
& + input[type="range"][multiple] {
margin-top: $multiRangeHeight * -1;
}
}
@mixin multirange-thumb {
pointer-events: all;
}
input[type="range"]::-webkit-slider-thumb {
@include multirange-thumb;
}
input[type="range"]::-moz-range-thumb {
@include multirange-thumb;
}
input[type="range"]::-ms-thumb {
@include multirange-thumb;
}
body {
padding: 30px;
}
input[type=range] {
/*removes default webkit styles*/
-webkit-appearance: none;
/*fix for FF unable to apply focus style bug */
border: 1px solid white;
/*required for proper track sizing in FF*/
width: 300px;
}
input[type=range]::-webkit-slider-runnable-track {
width: 300px;
height: 5px;
background: #ddd;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
margin-top: -4px;
position: relative;
z-index: 1;
}
input[type=range]:focus {
outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #ccc;
}
input[type=range]::-moz-range-track {
width: 300px;
height: 5px;
background: #ddd;
border: none;
border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
}
/*hide the outline behind the border*/
input[type=range]:-moz-focusring{
outline: 1px solid white;
outline-offset: -1px;
}
input[type=range]::-ms-track {
width: 300px;
height: 5px;
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
background: transparent;
/*leave room for the larger thumb to overflow with a transparent border */
border-color:...
JavaScript
var elm = document.querySelector('input');
var container = elm.parentNode;
var values = elm.getAttribute('data-values').split(' ');
values.forEach(function (value, i, values) {
var rangePart = elm.cloneNode();
rangePart.type = 'range';
rangePart.removeAttribute('data-values');
rangePart.value = value;
rangePart = container.insertBefore(rangePart, elm);
});
elm.remove();