Back

How to Add a Custom Scrollbar to Your Webflow Site

Learn how to easily customize your Webflow site's scrollbar with a simple code snippet.

Introduction

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.

Requirements

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.

Code Explanation

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>

Adding the Code to Webflow

To add the custom scrollbar to your entire Webflow project, follow these steps:

  1. Open your Webflow project: Go to the Webflow Designer for your site.
  2. Access Site Settings: Click on the project settings gear icon in the top left corner of the Designer.
  3. Navigate to Custom Code: In the Site Settings, go to the "Custom Code" tab.
  4. Add custom code: Scroll down to the "Head Code" section and paste the provided code snippet.
  5. Save and publish: Save your changes and publish your site and test the custom scrollbar in action. If required, make changes until you have the result you are looking for.

Detailed Breakdown

Let's go through the CSS code step by step:

Scrollbar width

::-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.

Scrollbar track

::-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.

Scrollbar thumb

::-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.

Browser Compatibility

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.

Conclusion

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.

Looking to build a Webflow site?

Get in Touch!

Let's bring your
ideas to life!