Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the Bootstrap 4 range slider colors?

enter image description here

Is there any ideas how to customize bootstrap 4 ranges colors and change blue thumb color to 'gray'?

Input html below.

<p id="slider" class="range-field">
  <input 
    type: "range",
    min:"0" max:"3"
    class: "custom-range"
    value: "2"
    disabled: "true"
  />
</p>
like image 664
Nerius Jok Avatar asked Jun 03 '19 09:06

Nerius Jok


People also ask

How do you style range input?

To style the range input with CSS you'll need to apply styles to two pseudo-elements: ::-webkit-slider-thumb and ::-webkit-slider-runnable-track . Find out how you can apply custom styling and make the range input more functional and appealing. Contents of the article: CSS selectors for the range input.

Does bootstrap have a slider?

Bootstrap slider is an interactive component that lets the user swiftly slide through possible values spread over a desired range. Note: You can also see multi-range sliders, but remember, that they do not work with this plugin.


2 Answers

Try the following code - various vendor-specific classes, use depending on your requirement needs:

.custom-range::-webkit-slider-thumb {
  background: gray;
}

.custom-range::-moz-range-thumb {
  background: gray;
}

.custom-range::-ms-thumb {
  background: gray;
}

Per comments by Astariul and aliawadh980, change the shadow that occurs when the thumb is clicked like this:

-webkit-slider-thumb:active {
    background-color: red;
}
-webkit-slider-thumb,
.custom-range:focus::-webkit-slider-thumb, 
.custom-range:focus::-moz-range-thumb,
.custom-range:focus::-ms-thumb {
    box-shadow: red;
}
like image 102
scooterlord Avatar answered Sep 23 '22 03:09

scooterlord


If you are using Sass you have to change (overwrite) value of $custom-control-indicator-checked-bg variable from _variables.scss.

Default value of $custom-control-indicator-checked-bg is:

$component-active-bg: theme-color("primary") !default;
// ...
$custom-checkbox-indicator-indeterminate-bg: $component-active-bg !default;
like image 20
Cichy Avatar answered Sep 25 '22 03:09

Cichy