Do you want to add a custom scrollbar in WordPress?
Changing how the scrollbar looks can help your site stand out, particularly if you are creating a custom WordPress theme. It can also draw the visitor’s attention to the scrollbar and encourage them to explore more of your content.
In this article, we will show you how to easily add a custom scrollbar in WordPress.
Why Add a Custom Scrollbar in WordPress?
In 2018, the WC3 drafted a proposal that allowed website owners to customize how the scrollbar looks using CSS.
Today, many modern browsers support custom scrollbars.
With that in mind, you may want to change the scrollbar better to suit your site’s color scheme or branding. Many websites also use a custom scrollbar to grab the visitor’s attention, which can increase your pageviews and reduce your bounce rate.
However, keep in mind that every browser handles custom scrollbars differently. Many browsers only partly support customization, while some won’t show your custom styling at all.
This means it’s important to test your site with different browsers and devices to see how the scrollbar looks across as many browsers as possible.
Having said that, let’s take a look at how to add a custom scrollbar in WordPress. Simply use the quick links below to jump to the method you want to use:
Method 1: Add a Custom Scrollbar in WordPress With a Plugin (Easy)
The easiest way to customize the scrollbar is by using Advanced Scrollbar. This free plugin lets you change the scrollbar’s width, color, scroll speed, and more without having to write a single line of code.
Upon activation, head over to Settings » Advanced Scrollbar Settings.
Here, you can change the scrollbar’s color scheme and rail background color.
In the following image, we have created a blue scrollbar.
You can also change the mouse scroll step by typing a new number into the ‘Mouse Scroll Step’ field.
A lower number will make your site scroll more slowly, and a higher number will make it scroll more quickly.
You can also select whether you want to auto-hide the scrollbar so that it only appears when the visitor is scrolling.
This can be useful if you have created a more colorful scrollbar and are worried it might distract from the rest of your content.
By default, the scrollbar will appear on the right side of the browser window. If you prefer, then you can move it to the left-hand side using the ‘Rail Align’ settings.
When you are happy with how the scroll bar is set up, don’t forget to click on ‘Save Changes’ to store your settings.
You can now visit your WordPress website to see the custom scrollbar in action.
Method 2: Add Custom Scrollbar Colors in WordPress Using CSS
If you want to make more advanced changes to your scrollbar, then another option is to use CSS.
This method lets you customize every part of the scrollbar, but it only works on desktop browsers using WebKit. This means your changes won’t show up on all browsers, including mobile browsers.
To customize your scrollbar using CSS, go to Appearance » Customize.
Note: If you are using a block theme, then this option won’t be available for you. In that case, you can open the customizer by typing in the https://example.com/wp-admin/customize.php URL. Keep in mind to replace example.com with your own site’s domain name.
In the WordPress customizer, click on ‘Additional CSS’.
You can now add your code to the small editor that appears.
Here’s an example of code that changes how the scrollbar looks:
border:1px solid #ccc;
border:1px solid #eee;
You can add any code you want. For more information on CSS, please see our complete guide on how to add custom CSS to your WordPress theme.
When you are happy with your code, just click on the ‘Publish’ button. You can now visit your WordPress blog in a WebKit browser to see your changes in action.
Bonus: Add a Scroll to Top Effect in WordPress
Apart from creating a custom scrollbar, you may also want to add a scroll-to-top effect on your WordPress site. This can be super helpful if you have longer blog posts and want to provide users with a quick way to get back to the top.
Upon activation, visit the Settings » Scroll Top page from the WordPress dashboard and check the ‘Enabled’ box to activate the scroll to top effect.
After that, you can edit the scroll offset, button size, opacity, fade duration, scroll duration, and more from here.
Once you are done, don’t forget to click the ‘Save Changes’ button to store your settings.
You have now successfully added a scroll-to-top effect on your website. For more detailed instructions, see our tutorial on how to add a smooth scroll to top effect in WordPress.
We hope this article helped you learn how to add a custom scrollbar in WordPress. You may also want to see our guide on how to create a landing page in WordPress or see our expert picks for the best drag and drop page builders.