CSS Shorts: Lets Build a Custom Scroll bar

bkanhu

B Kanhu Charan

Posted on January 6, 2022

CSS Shorts: Lets Build a Custom Scroll bar

Lets face it. We as developers and designers spends hours on designing the webpage that should looks good, feels good and drive sales/convert customer. We spends hours on micro-animations. Then Why not design the scroll too. In this artile I'll show you how to do that.

The scrollbar has basically 2 components. That is scrollbar-track and scrollbar-thumb.
And we need to tweek ::-webkit-scrollbar pseudo element to modify the look of the browser's scrollbar.

Here the code that you need to design a simple scrollbar which has a width of 10px, A black trackbar and a red thumb.
Image description

::-webkit-scrollbar {
    width: 10px;
  }

  ::-webkit-scrollbar-track {
    background: #ff2b2b;
  }

  ::-webkit-scrollbar-thumb {
    background: #ff5252;
  }
Enter fullscreen mode Exit fullscreen mode

That's it? Well you can use vertical-scroll::-webkit-scrollbar-track {} to design the horizontal scrollbar.
You can use other css properties background, border-radius, box-shadow and similar.

💖 💪 🙅 🚩
bkanhu
B Kanhu Charan

Posted on January 6, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related