In this guide, we'll show you how to add a custom scrollbar to your Webflow site. Since this feature can't be achieved directly through the Webflow interface, we'll need to add a simple code snippet. By the end of this article, you'll have a stylish scrollbar that matches your site's design.
Customizing the scrollbar on your Webflow site requires adding a few lines of CSS code. Webflow’s designer doesn’t have a built-in feature for scrollbar customization, so we’ll be using custom code instead.
Below is an example of a custom scrollbar code snippet. We'll break down what each section does to help you understand how to implement and modify it.
<style>
/* Scrollbar width */
::-webkit-scrollbar {
width: 12px; /* Adjusts the width of the scrollbar */
}
/* Scrollbar track (the background of the scrollbar) */
::-webkit-scrollbar-track {
background: #f1f1f1; /* Sets the color of the scrollbar track. Set in HEX values */
}
/* Scrollbar thumb (the draggable part) */
::-webkit-scrollbar-thumb {
background: #4591ed; /* Sets the color of the scrollbar thumb */
border-radius: 6px; /* Rounds the corners of the scrollbar thumb. Set in pixels */
}
</style>
To add the custom scrollbar to your entire Webflow project, follow these steps:
Let's go through the CSS code step by step:
::-webkit-scrollbar {
width: 12px; /* Adjusts the width of the scrollbar */
}
The ::-webkit-scrollbar
selector targets the entire scrollbar. The width
property sets the scrollbar's width. You can customize this value to make the scrollbar thinner or thicker.
::-webkit-scrollbar-track {
background: #f1f1f1; /* Sets the color of the scrollbar track */
}
The ::-webkit-scrollbar-track
selector targets the background of the scrollbar. The background
property changes its color. You can use any HEX color value to match your site's design.
::-webkit-scrollbar-thumb {
background: #4591ed; /* Sets the color of the scrollbar thumb */
border-radius: 6px; /* Rounds the corners of the scrollbar thumb */
}
The ::-webkit-scrollbar-thumb
selector targets the draggable part of the scrollbar. The background
property changes its color, and you can use any HEX color value here as well. The border-radius
property rounds the corners of the scrollbar thumb, giving it a rounded look.
The custom scrollbar styling using ::-webkit-scrollbar
works primarily in WebKit browsers (like Chrome, Edge, Brave, Arc and Safari). Other browsers may not support this pseudo-element, so it's good practice to test your site in different browsers to ensure a consistent user experience.
Adding a custom scrollbar to your Webflow site is a straightforward process that involves inserting a small piece of CSS code. This customization enhances the user experience and aligns your scrollbar with your site's design. Try out the example provided and tweak the values to fit your branding or creative ideas.