scrollbar-width

Term side of the Card.
Topic: Client Interface
Unit title: scrollbar-width
Categories: Property
Explanation side of the Card

Explanation: The property that adjusts the width of the scrollbar. It can be set to 'auto', 'thin' or 'none', allowing for customization of scrollbar appearance and behavior, especially useful for creating cleaner and more minimalist designs.

Browser compatibility:
  • The chrome browser supports this feature starting from version 121.
  • The edge browser supports this feature starting from version 121.
  • The firefox browser supports this feature starting from version 64.
  • The safari browser supports this feature starting from version 18.2.
Availability: 

Example

Wrongcss
.carousel {
  scrollbar-width: 4px;
}
Rightcss
.carousel {
  scrollbar-width: thin;
}

scrollbar-width only accepts 'auto', 'thin' or 'none'; a pixel length is invalid and the declaration is ignored.

Common mistakes

  • Setting a pixel value like '8px', which is invalid and ignored.
  • Hiding the scrollbar so users don't notice the area can scroll.

Key points

  • Values are the keywords 'auto', 'thin' or 'none', not pixel lengths.
  • 'none' is used only where content can still be scrolled with keyboard, touch or visible controls.
  • Scrollbars are hidden with scrollbar-width: none, not only with ::-webkit-scrollbar { display: none }.

Interview questions

How do I hide the scrollbar but keep scrolling?

Set scrollbar-width: none on the scroll container. The content still scrolls with wheel, touch and keyboard.

Can I set an exact scrollbar width in pixels?

No. The standard property only takes keywords; the exact size of 'thin' is chosen by the browser.

Is scrollbar-width inherited?

No. Set it on each scroll container whose scrollbar you want to change.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy