Git Product home page Git Product logo

input-range-scss's Introduction

Styling Cross-Browser Compatible Range Inputs with Sass / SCSS

Sass component for customizing the input range using the native properties of each browser. Based on article Styling Cross-Browser Compatible Range Inputs with CSS from CSS Tricks blog.

NPM Package

npm i input-range-scss

Features

  • Variables for easy customization
  • Uses the native properties of each browser
  • Preserves accessibility
  • Cross-browser compatible

Example

Input range native and custom on browsers

Usage

To use this library in your stylesheets, import it as a Sass module:

@use 'input-range-scss';

To override the default styling, use the with keyword along with any variables you would like to override, for example:

@use 'input-range-scss' with (
  $track-color: red,
  $thumb-color: blue,
  $thumb-height: 2em,
  $thumb-width: 2em,
);

For a complete list of variables see https://github.com/darlanrod/input-range-scss/blob/master/_inputrange.scss#L9.

NB. including the module will apply styles all elements matching the CSS selector [type='range'].

Changelog

To see the change history of this project, check out the changelog.md file.

See Also

Input range browser support

input-range-scss's People

Contributors

beepye avatar cookpete avatar darlanrod avatar deanpoulin avatar guidezpl avatar jenstornell avatar jshakes avatar mpavel avatar n0nick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

input-range-scss's Issues

Track width webkit/moz inconsistency

I see that this issue is addresed by the following:

&::-moz-range-track {
  height: $track-height / 2;
}

However applying tweaks to the variables reveals that this is not a perfect solution as with different $track-width and $track-border-width values the overall widths of the track diverge. I suggest this works better (instead of the rule above):

&::-moz-range-track {
  box-sizing: border-box;
}

[Question] Rotating the thumb

Hey,
I have some special styling for the thumb, where it needs to be a diamond shaped thumb.

I added a transform: rotate(45deg); to the thumbs, but in IE11 it cuts off the edges.
Do you have an idea how to fix this? Or probably a different solution?

Using "/" in Sass is deprecated; use math.div instead

Hello, according to this using the slash as the division operator is not supposed to be done in Sass anymore and will eventually break, and when I use your package Webpack issues many deprecation warnings about it. Since this is a very straightforward problem, I made the relevant changes to my own fork and will open a pull request for it.

How to add filled part?

Hello, any ideas on how to add custom filled part in the left part of the slider? like on screenshot has IE in default.

NPM package?

Are there any plans to turn this into a simple npm package? Or it's already there and I'm missing it?

Question: Sliders of different colors in single page

Hi, is there a way to make the sliders of different colors in the same page?

.sliderblue {
track-color: blue;
}
.slideryellow {
track-color: yellow;
}

does not work independently from adding the @import or @use or inserting the full scss code in the main css file. Adding !global in the class changes the color but also previous ones.

Input elements should not have cursor:pointer

cursor:pointer; should be reserved for links and link-like elements only. As module can be seen as an implementation of best practices, I would recommend to switch to cursor:default, which would be the most appropriate choice.

I can provide a PR, but I'm about to leave the office right now, will check this issue later.

Vertical Sliders

Styling sliders is easy, as long as they are not vertical.
Unfortunately, I need vertical sliders to implement virtual scrolling.
Your repo does what's easy, but not what's hard.

Dotted Ouline On Track When Using Slider

When I use the slider, it has a dotted outline. I see the rule in the SCSS for:

  &:focus {
    outline: 0;
    ...
  }

but I'm still seeing a dotted outline, at least in the latest Firefox.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.