DEV Community

Cover image for Getting rid of ugly scrollbars using Overlayscrollbars
Sebastian Kurpiel
Sebastian Kurpiel

Posted on • Updated on

Getting rid of ugly scrollbars using Overlayscrollbars

At Draftbit we were running into an issue where when a user plugged in a mouse into their machine, any scrollable content would render with the default styled macOS scrollbars.
MacOS scrollbars when mouse is plugged in
As you can tell, that's not the prettiest look and the scrollbars take up a bit of space in their div. The situation on windows machines wasn't any better as scrollbars are always rendered no matter what.
Windows scrollbars always rendering oof
The quick and easy solution is to use css,

.scrollBar { //Needed for Mozilla when applying overflow:scroll or auto
  scrollbar-width: none;
::-webkit-scrollbar { //Needed for Chrome and Safari
  width: 0px;

::-webkit-scrollbar-track-piece {
  background-color: transparent;
  -webkit-border-radius: 6px;

Enter fullscreen mode Exit fullscreen mode

No scrollbars rendered
This will remove the scrollbars and still allow for scrolling, however it removes the indicator showing the user how far they have scrolled. This causes issues with accessibility and isn't the route we wanted to go.

After discussing possibilities including scroll hijacking we settled on using OverlayScrollbars, a library which hides native scrollbars and replaces them with styleable overlay scrollbars.

To integrate we did the following:

  • create a wrapper component, ScrollContainer, which uses Overlayscrollbars' OverlayScrollbarsComponent
  • apply the appropriate styles to the component, for us the os-theme-dark was perfect for the dark theme of our builder.
  • apply options to achieve the scrollbar behaviour that we needed, for our needs we wanted the scrollbars to hide when the user was not scrolling so we enable autohide
  • we then searched the entire app to find where we were using overflow:auto or overflow:scroll.
  • if found we would replace that div with ScrollConatiner and apply the proper tailwind classNames.

OverlayScrollbars, no scrollbars

And BOOM,like that, Draftbit was free of those ugly scrollbars and in their place were some sleek scrollbars that work and look good. If you enjoy making apps look good and want to enter the no-code space, Draftbit is hiring! Come check out how we're making app-building accessible to everyone!


import * as React from "react";
import { OverlayScrollbarsComponent } from "overlayscrollbars-react";

const ScrollContainer = ({ className, children }) => {
  return (
      className={"os-theme-dark " + className}
      options={{ scrollbars: { autoHide: "scroll" } }}>

export default ScrollContainer;
Enter fullscreen mode Exit fullscreen mode
import * as React from "react";
import ScrollContainer from "/ScrollContainer"

const PanelThatNeedsToBeScrollable = () => {
  return (
    <ScrollContainer className="p-4 mt-4">
        <span className="tallerThanHeightOfScreen"> I'm so tall that my content needs to scroll!!! </span>

Enter fullscreen mode Exit fullscreen mode

Top comments (1)

muffenme profile image
Mike Blais

I hate overlay-scrollbars, I want the classic scrollbar.