Developer and Text Tools

Custom Scrollbars in CSS: What Works in Chrome, Firefox and Safari Today

scrollbar-color, scrollbar-width and ::-webkit-scrollbar explained, why old snippets stopped working in Chrome, and how to style or hide scrollbars well.

Saizul Amin
Saizul Amin5 Nov 2026 · 4 min read
Custom Scrollbars in CSS: What Works in Chrome, Firefox and Safari Today

A chat panel, a code box or a dark sidebar often looks wrong with the default grey scrollbar. Styling scrollbars used to be a WebKit-only trick, and Firefox had its own simpler properties. In early 2024, Chrome and Edge started supporting the standard properties too, and many older snippets suddenly stopped working there. Here is how scrollbar styling works now and how to write CSS that covers every browser.

Two layers of CSS

The standard properties come from the CSS Scrollbars specification and are supported by Firefox and by Chrome and Edge from version 121:

  • scrollbar-color sets two colours, the thumb and the track.
  • scrollbar-width sets auto, thin or none. There is no exact pixel width.
  • scrollbar-gutter: stable reserves space for the scrollbar so the layout does not shift when content grows.

The WebKit pseudo-elements are older and more detailed: ::-webkit-scrollbar for the overall size, -track for the background, -thumb for the draggable part, -corner where two bars meet, and -button for the arrows. They allow exact widths, rounded thumbs and hover colours. Safari still relies on them.

The important rule: in Chrome and Edge 121 and later, as soon as scrollbar-color or scrollbar-width is set on an element, the WebKit rules for that element are ignored. That is why a snippet with both layers may look different from what you expect in Chrome, and why some old snippets that only used WebKit rules still work there while new ones with both do not show hover colours. Writing both layers on purpose, standard first and WebKit second, gives every browser a styled bar.

Styling the page or one box

You can style the whole page by targeting html for the standard properties and the bare ::-webkit-scrollbar selectors. Many designers prefer to style only specific scrolling areas, such as a sidebar or a chat list, through a class. People are used to their system's page scrollbar, and system bars respect accessibility settings such as larger scrollbars.

Making the thumb easy to find

WCAG 1.4.11 asks that parts of controls people need to see have a contrast of at least 3 to 1 against what is next to them. A pale thumb on a white track is stylish and hard to find. Check the thumb colour against the track colour, in light and dark mode.

Width matters too. A common trick adds a border in the track colour around the thumb, so it looks like it floats inside the track. The visible thumb is then narrower than the bar. Below about 6 pixels it becomes hard to grab with a mouse.

Building one with the generator

The CSS Scrollbar Generator writes both layers for you.

  1. Choose where it applies. One scrolling box with a class name, or the whole page.
  2. Start from a style. Slim grey, a macOS-like overlay look, brand blue, square classic with arrow buttons, a dark terminal style or hidden but scrollable.
  3. Set colours and size. Thumb, hover, dragging and track colours, the WebKit width in pixels, the standard thin or auto width, thumb rounding and the gap around the thumb.
  4. Set the extras. A dark-mode colour pair, arrow buttons, a rounded track, a stable gutter, or standard properties only if you do not need Safari styling.
  5. Check the preview. Scroll the sample box in both directions, hover the thumb, and switch the preview to dark mode.
  6. Copy the CSS. Add the class to your scrolling element and make sure it has a fixed height or max-height so it can scroll.

Hiding scrollbars

Horizontal strips of cards, chips or images often look cleaner without a bar. scrollbar-width: none and display: none on the WebKit bar hide it, and the content still scrolls with touch, trackpad, wheel and keyboard. Give people another clue that more content exists, such as a fade at the edge, arrows or part of the next card peeking in.

Phones and macOS

On iOS and Android, browsers draw thin overlay scrollbars that appear only while scrolling and mostly ignore custom styles. On macOS, scrollbars are hidden until scrolling unless the system setting is Always. So custom scrollbars are mainly a desktop design detail, and the layout should never depend on them.

A short checklist

Use the standard properties for Chrome and Firefox and the WebKit rules for Safari. Keep the thumb at 3 to 1 contrast or better. Leave enough thumb width to grab. Provide dark-mode colours if your site has a dark theme. And when you hide a scrollbar, show another sign that the area scrolls.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages