How to Customize the Scrollbar in CSS

If you’ve ever wanted to match your website’s scrollbar with your design system, CSS now lets you fully customize it. In this tutorial, we’ll walk through a simple, modern, and responsive way to style scrollbars that works across major browsers — without any JavaScript or plugins.
Author:
|
CTO of
Quanta Digital Agency
Published
If you'd like someone to take care of your marketing, I'm here to help, Click Here

Responsive Desktop-Only Scrollbar Styling

Mobile browsers such as Safari (iOS) and Chrome (Android) either hide the scrollbar or render it as a transparent overlay, which means CSS customization doesn’t apply there.

Responsive Desktop-Only Scrollbar Styling
To keep the mobile experience clean and consistent, you can restrict your custom scrollbar to desktop screens only using a simple media query:

@media (min-width: 1024px) {
  :root {
    --scrollbar-track: #292929;   
    --scrollbar-thumb: #fff9b1;   
  }

  html {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  }

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

  ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }

  ::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 6px;
  }
}

Where to add the code

You can safely paste this CSS snippet inside your theme’s Additional CSS section

(WordPress Dashboard → Appearance → Customize → Additional CSS),

or include it in your theme’s main stylesheet (style.css).

wordpress Customize

Customize Colors Easily

Since we used CSS variables, you can change the look by editing only two lines:

:root {
  --scrollbar-track: #111;
  --scrollbar-thumb: #00bcd4;
}
  • The track represents the background area where the scrollbar moves — like a rail.
  • The thumb is the draggable part that indicates the current scroll position.

You can adjust these two colors anytime without touching the rest of the code.

Leave a Reply

Your email address will not be published. Required fields are marked *

Practical Web Tutorials for WordPress Designers, Developers & SEO Experts on My YouTube Channel
Do you want
 more traffic from Google?

About Peyman Farahani

Peyman Farahani is CTO of Quanta Digital Agency

As a digital problem-solver with a focus on SEO, WordPress, and performance-first design, I’ve helped clients achieve real digital results.

I connect creativity with execution — exploring market gaps, shaping clear ideas, and building solutions that actually make an impact.