

Classy and Cool Custom CSS Scrollbars: A Showcase | CSS-Tricks - CSS-Tricks
source link: https://css-tricks.com/classy-and-cool-custom-css-scrollbars-a-showcase/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Classy and Cool Custom CSS Scrollbars: A Showcase
DigitalOcean provides cloud products for every stage of your journey. Get started with $200 in free credit!
In this article we will be diving into the world of scrollbars. I know, it doesn’t sound too glamorous, but trust me, a well-designed page goes hand-in-hand with a matching scrollbar. The old-fashioned chrome scrollbar just doesn’t fit in as much.
We will be looking into the nitty gritty details of a scrollbar and then look at some cool examples.
Components of a scrollbar
This is more of a refresher, really. There are a bunch of posts right here on CSS-Tricks that go into deep detail when it comes to custom scrollbar styling in CSS.
To style a scroll bar you need to be familiar with the anatomy of a scrollbar. Have a look at this illustration:

The two main components to keep in mind here are:
- The track is the background beneath the bar.
- The thumb is the part that the user clicks and drags around.
We can change the properties of the complete scrollbar using the vendor-prefixed::-webkit-scrollbar
selector. We can give the scroll bar a fixed width, background color, rounded corners… lots of things! If we’re customizing the main scrollbar of a page, then we can use ::-webkit-scrollbar
directly on the HTML element:
html::-webkit-scrollbar {
/* Style away! */
}
If we’re customizing a scroll box that’s the result of overflow: scroll
, then we can use ::-webkit-scrollbar
on that element instead:
.element::-webkit-scrollbar {
/* Style away! */
}
Here’s a quick example that styles the HTML element’s scrollbar so that it is wide with a red background:
What if we only want to change the scrollbar’s thumb or track? You guessed it — we have special prefixed pseudo-elements for those two: ::-webkit-scrollbar-thumb
and ::-webkit-scrollbar-track
, respectively. Here’s an idea of what’s possible when we put all of these things together:
Enough brushing up! I want to show you three degrees of custom scrollbar styling, then open up a big ol’ showcase of examples pulled from across the web for inspiration.
Simple and classy scrollbars
A custom scrollbar can still be minimal. I put together a group of examples that subtly change the appearance, whether with a slight color change to the thumb or track, or some light styling to the background.
As you can see, we don’t have to go nuts when it comes to scrollbar styling. Sometimes a subtle change is all it takes to enhance the overall user experience with a scrollbar that matches the overall theme.
Cool eye-catching scrollbars
But let’s admit it: it’s fun to go a little overboard and exercise some creativity. Here are some weird and unique scrollbars that might be “too much” in some cases, but they sure are eye-catching.
One more…
How about we take the scrollbar for a spin in a train for the thumb and tracks for the, well, the track!
</article
Recommend
-
41
GitHub is where people build software. More than 28 million people use GitHub to discover, fork, and contribute to over 85 million projects.
-
60
fakeScroll Very lightweight & robust custom-looking HTML scrollbar script. 1.4KB gzipped (js) 4.0KB minified (js)...
-
41
If you need to style your scrollbars right now, one option is to use a collection of ::webkit prefixed CSS properties. ...
-
13
`content-visiblity` Without Jittery Scrollbars December 4, 2020Update: After further investigation, an even b...
-
6
Custom Scrollbars In CSS 22 Jun 2021 Custom scrollbars are getting more popular nowadays, and I’m very keen to dig into them. There are different reasons why to customize a scrollbar. For example, the default scrollb...
-
9
Why Overly Scrollbars? Overlay scrollbars are great because they don't affect the width of the content as they appear and disappear. When I discovered this trick, I was specifically looking to solve the problem of content ref...
-
7
Building like it's 1984: Scrollbars in web applicationsSimilar to
-
6
How to Customize the Scrollbars on Windows 10 and 11 By Neeraj Paruthi Published 4 hours ago Are Windows' de...
-
14
Dress up iPhone 14 in a classy and protective leather case
-
8
Don’t use custom CSS scrollbars In the spirit of “everything old is new again,” browsers are once again supporting the ability to style...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK