One day some designers provide you with beautiful mock-ups 🌠 and … custom macOS-like scrollbars which look like:
But maybe on the left, smaller or bigger, with different indents dependent on whether it’s mobile 📱, desktop 🖥️ or TV screen 📺 Asking more?
But the reality is… a customisation of scrollbars remains same since the end of 90s. If my dad was programming, he would make fun of me all day while I found the solution to make everything universal and stable. It’s 2020 and it’s still a PITA.
✅ Webkit and Blink
Since Firefox 64 was released, scrollbar customisation is now available.
I remind you, that original bug was reported 18 years ago, only less than 1 year ago implementation of CSS Scrollbars Module Level 1 was considered 😔.
Yet it’s not working for me when you try this chunk of CSS:
scrollbar-color: rebeccapurple green;
Check it in your FF, mine is not working with this.
However, if you try this, it works perfect:
If you are not familiar with it, probably forget about it. It’s IE11. Such a pain everywhere. Maybe not supporting it at all?
However, even it has CSS properties which might help:
And also autohiding scrollbar property!!! Thanks 🙏⚡
Another one is EdgeHTML which is a fork of Trident and used in old Edge. It had only enhancement in its backlog with medium priority to add support for scrollbar styling. But since Edgium release you can use Webkit / Blink pseudo elements 🎉.
CSS Hacks and tricks
Slowly but surely we achieve what we want.
Scrollbar on the left
Turn scrollbar on with JS
Accepting the fact FF, Edge and IE do not support scrollbar customisation, JS library might be not bad solution for them.
A size of scrollbar JS bundle should be worth it. However it’s not what it’s expected.
lib / minified in KB / minified + gzipped in KB
🕳️ size of black hole
nanoscroller / 94.2 / 32.4 (with jQ)
simplebar / 63.5 / 19 (with lodash, resize observer polyfill and core-js)
iscroll / 32.1 / 8.3
perfect-scrollbar / 17.7 / 5.1
jscrollpane / 15.7 / 5.2
🤘 light enough
nanoscroller / 8.31 / 2.89 (without jQ)
slim-scroll / 4.2 / 1.8
🔥 too good to be true
simple-scrollbar / 2.3 / 0.97
Bundlephobia helps evaluating sizes of bundles.
Of course, good options are lightweight vanilla libraries.
Some of choices like simple-scrollbar provide scrollbars unfriendly for mobile devices. It is required to add a lot of functionality and therefore not production-ready.
slim-scroll is created by a stack overflow user and is aimed to improve design on Windows. That’s good as macOS scrollbar looks good everywhere. However, native customisation is only available on WebKit and Blink.
Have a productive week 💪
Probably you want to customise you own scrollbar. First have a look at scrollbar mechanics.
⭐⭐️ Google Developers: CSS Deep-Dive: matrix3d() For a Frame-Perfect Custom Scrollbar
⭐⭐️️ CSDGN: Scrollbar Mechanics
⭐️ CSS Tricks: Custom Scrollbars in WebKit
📄 MDN: CSS scrollbars
📄 W3School: How To Create Custom Scrollbars
📄 Stack Overflow: Hide scroll bar, but while still being able to scroll
📄 Stack Overflow: Custom CSS Scrollbar for Firefox
📄 Stack Overflow: CSS customized scroll bar in div