Skip to content

Instantly share code, notes, and snippets.

@iosorin
Created November 8, 2020 02:44
Show Gist options
  • Select an option

  • Save iosorin/89b6e7d07610103238af827f8e932c42 to your computer and use it in GitHub Desktop.

Select an option

Save iosorin/89b6e7d07610103238af827f8e932c42 to your computer and use it in GitHub Desktop.
range.scss
$color: #f2f5f9;
$activeColor: #6666fe;
$thumbColor: #6666fe;
$trackHeight: 5px;
$thumbHeight: 12px;
$progressPercent: 50%;
@mixin thumb {
appearance: none;
width: $thumbHeight;
height: $thumbHeight;
background-color: $thumbColor;
border-radius: $thumbHeight / 2;
border: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
margin-top: (($thumbHeight - $trackHeight) / 2) * -1;
cursor: pointer;
}
@mixin track {
height: $trackHeight;
background-color: $color;
border-radius: $trackHeight / 2;
}
@mixin progress {
height: $trackHeight;
background-color: $activeColor;
border-radius: (($trackHeight / 2) 0 0 $trackHeight) / 2;
}
.range {
/* reset... */
appearance: none;
height: $thumbHeight;
&:focus {
outline: none;
}
&:disabled {
user-select: none;
opacity: 0.6;
}
/* Thumb */
&::-webkit-slider-thumb {
-webkit-appearance: none;
@include thumb;
}
&::-moz-range-thumb {
-moz-appearance: none;
@include thumb;
}
&::-ms-thumb {
-ms-appearance: none;
@include thumb;
}
/* Track */
&::-webkit-slider-runnable-track {
@include track;
}
&::-moz-range-track {
@include track;
}
&::-ms-track {
@include track;
}
/* Progress */
&::-moz-range-progress {
@include progress;
}
&::-ms-fill-lower {
@include progress;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment