Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom range styles #19468

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/components/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -1022,3 +1022,11 @@ $custom-file-text: (
{% endhighlight %}

You'll need to set the language of your document (or subtree thereof) correctly in order for the correct text to be shown. This can be done using [the `lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) or the [`Content-Language` HTTP header](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12), among other methods.

### Range input

Custom `<input type="range">` need only a custom class, `.custom-range` to trigger the custom styles.

{% example html %}
<input type="range" class="custom-range">
{% endexample %}
74 changes: 74 additions & 0 deletions scss/_custom-forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,77 @@
}
}
}


// Range
//
// Replace the browser default range with a custom one
.custom-range {
height: $input-height;
margin-bottom: $input-height;
border: $input-btn-border-width solid $input-border-color;
@include border-radius($input-border-radius);
-webkit-appearance: none;
@include box-shadow($input-box-shadow);
@include transition(border-color ease-in-out .15s, box-shadow ease-in-out .15s);
@include form-control-focus();

&::-webkit-slider-runnable-track {
height: $input-height;
background: transparent;
border: 0;
}
&::-webkit-slider-thumb {
width: ($input-height + .125rem);
height: $input-height;
border: $input-btn-border-width solid $input-color;
@include border-radius($input-border-radius);
-webkit-appearance: none;
}

&::-moz-range-track {
height: $input-height;
background: transparent;
border: 0;
}
&::-moz-range-progress {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Begin pseudo classes with a single colon: :

height: $input-height;
background: $brand-primary;
}
&::-moz-range-thumb {
width: ($input-height + .125rem);
height: $input-height;
border: $input-btn-border-width solid $input-color;
@include border-radius($input-border-radius);
-moz-appearance: none;
}
&::-moz-focus-inner {
border: 0;
}

&::-ms-track {
height: $input-height;
// remove default tick marks
color: transparent;
// 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: transparent;
border-width: 6px 0;
}
&::-ms-fill-lower {
background: $brand-primary;
@include border-radius($input-border-radius);
}
&::-ms-fill-upper {
background: transparent;
@include border-radius($input-border-radius);
}
&::-ms-thumb {
width: ($input-height + .125rem);
height: $input-height;
border: $input-btn-border-width solid $input-color;
@include border-radius($input-border-radius);
}
}