CSS scrollbar generator

This CSS scrollbar generator styles a scrollbar from one set of colour and width controls, writing scrollbar-color and scrollbar-width for Firefox and ::-webkit-scrollbar rules for Safari and older Chrome.

To style a scrollbar in CSS, set scrollbar-color and scrollbar-width for Firefox and current browsers, and ::-webkit-scrollbar rules for Safari and older Chrome. This generator writes both from one set of controls.

How to use the generator

  1. Pick a preset or set the thumb colour, hover colour and track colour with the colour pickers.
  2. Drag the width, radius and padding sliders, and tick the thin option if you want a slimmer bar.
  3. Scroll the live preview to check both directions, then copy the CSS and paste it into your stylesheet.

Live preview

Scroll this box to see the custom scrollbar. The content is long enough to overflow vertically, and the wide element below adds a horizontal scrollbar too.

Drag the thumb, then hover it to check the hover colour. The track colour and the padding around the thumb update as you move the sliders.

Use the presets for a quick starting point, then copy the CSS and paste it into your stylesheet. Replace the generated class with the element that should scroll.

That wide block forces the horizontal scrollbar so you can preview both directions at once.

Generated CSS

/* scrollbar-color makes Chrome 121+ ignore ::-webkit-scrollbar, so keep it for engines without WebKit scrollbar styling. */
@supports not selector(::-webkit-scrollbar) {
  .csg-preview-_R_pbsnmdb_ {
    scrollbar-width: auto;
    scrollbar-color: #94a3b8 #f1f5f9;
  }
}

.csg-preview-_R_pbsnmdb_::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.csg-preview-_R_pbsnmdb_::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.csg-preview-_R_pbsnmdb_::-webkit-scrollbar-thumb {
  background-color: #94a3b8;
  border-radius: 8px;
  border: 2px solid #f1f5f9;
}

.csg-preview-_R_pbsnmdb_::-webkit-scrollbar-thumb:hover {
  background-color: #64748b;
}

Which scrollbar CSS works in which browser

There are two ways to style a scrollbar and they do not overlap cleanly. The standard properties are the future-proof path, while the WebKit pseudo-elements give you the extra control that the standard properties do not expose. Check the current MDN compatibility table before you rely on a version number.

PropertyChrome/EdgeFirefoxSafari
scrollbar-color121+YesNot supported (check MDN)
scrollbar-width121+Yes18.2+
::-webkit-scrollbarYes, ignored when scrollbar-color is setNoYes

Frequently asked questions

How do I hide the scrollbar but keep scrolling?

Set scrollbar-width: none for Firefox and add ::-webkit-scrollbar { display: none } for Safari and older Chrome. The element still scrolls with the wheel, trackpad, keyboard and touch; only the visible bar disappears. Do not hide the scrollbar on main page content, because visitors lose the cue that there is more to read.

Why is my ::-webkit-scrollbar style ignored in Chrome?

Since Chrome 121, setting scrollbar-color or scrollbar-width makes the browser ignore the ::-webkit-scrollbar rules for that element. That is why the generated output wraps the standard properties in @supports not selector(::-webkit-scrollbar), so engines that support the WebKit pseudo-elements keep using them and the standard properties only apply where they are needed.

Can I round the scrollbar thumb?

Yes, but only through ::-webkit-scrollbar-thumb with border-radius, which works in Chrome, Edge and Safari. The standard scrollbar-color and scrollbar-width properties only set colour and width, so Firefox draws its own rounded thumb and ignores a custom radius. The generator still writes the radius for the WebKit engines.

Does a custom scrollbar hurt accessibility?

It can if the thumb blends into the track or becomes too thin to grab. Keep a clear contrast between thumb and track, do not make the bar thinner than about 8px for mouse users, and never hide the scrollbar on main content. A visible, high-contrast thumb helps people with low vision and motor difficulties find and drag it.

Related: build a CSS background pattern and add a box shadow to the same panel.

More CSS generators

Color tools

Image tools

Image & SVG tools

Typography & units

More free tools

All free tools