Thanks to visit codestin.com
Credit goes to www.cssportal.com

CSS Portal

CSS scrollbar-width Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The scrollbar-width property controls how thick an element’s scrollbar appears and how much horizontal space that scrollbar consumes beside scrollable content. It’s applied to the scroll container itself and directly influences the visual prominence of the scrollbar track and thumb — making the slider more or less noticeable and changing the amount of layout space reserved for the control. Because it is a presentation-level property, authors use it to tune how a scrolling interface integrates with surrounding UI elements and typography.

Because changing the thickness of scrollbars changes the space reserved for them, the property can affect layout and reflow: reducing scrollbar width can increase the area available to content, while widening it can reduce the content area and potentially introduce or remove overflow. That interaction makes it important to think about how it works together with scrolling behavior and overflow controls — for example, when you manage whether content scrolls or is clipped with overflow, the visual width of the scrollbar is one of the things that determines the final visible content area and hit targets for pointer interactions.

From a design and accessibility perspective, scrollbar-width is a tool for balancing aesthetics and usability. Thinner scrollbars can produce a cleaner, less cluttered layout, but very narrow controls may be harder to target with a mouse or to notice for users who rely on visual cues; conversely, thicker scrollbars can improve discoverability and hit area but reduce content space. It’s commonly used in conjunction with scrollbar color and contrast adjustments to create cohesive scrollbar styling — for example pairing it with scrollbar-color to control both thickness and appearance — while still being mindful that user agents, platform settings, and user preferences may alter or override the final rendering.

Practical use of the property should consider device differences (pointer vs. touch), the expectations of the target audience, and the interaction with custom scrolling solutions. Because scrollbar width influences layout, test changes on typical content lengths and viewport sizes to avoid accidental shifts or overflow changes. If a design requires very different scrollbar behavior (for example fully custom UI scrollers or hide-on-idle behavior), those needs are often handled with a combination of styling, layout adjustments, and script-driven custom scroll components rather than by width adjustments alone.

Definition

Initial value
auto
Applies to
scrolling boxes
Inherited
no
Computed value
as specified
Animatable
by computed value type
JavaScript syntax
object.style.scrollbarWidth

Syntax

scrollbar-width: auto | thin | none

Values

  • auto
  • thin
  • none

Example

<div class='scroll-demo'>
<h2>Scrollbar-width demo</h2>
<div class='content'>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Integer nec odio. Praesent libero. Sed cursus ante dapibus diam.</p>
<p>Sed nisi. Nulla quis sem at nibh elementum imperdiet.</p>
<p>Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.</p>
<p>Mauris massa. Vestibulum lacinia arcu eget nulla.</p>
<p>Class aptent taciti sociosqu ad litora torquent per conubia nostra.</p>
<p>In convallis. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis.</p>
</div>
</div>
/* Demo container */
.scroll-demo {
  width: 400px;
  height: 180px;
  margin: 24px auto;
  padding: 12px;
  border: 1px solid #d0d0d0;
  background: #fafafa;
  overflow: auto;

  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: #8b8b8b #e6e6e6;
}

/* WebKit browsers (Chrome, Edge, Safari) */
.scroll-demo::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.scroll-demo::-webkit-scrollbar-track {
  background: #e6e6e6;
  border-radius: 6px;
}

.scroll-demo::-webkit-scrollbar-thumb {
  background: #8b8b8b;
  border-radius: 6px;
  border: 2px solid #e6e6e6;
}

/* Content spacing */
.content p {
  margin: 8px 0;
  line-height: 1.4;
}

Browser Support

The following information will show you the current browser support for the CSS scrollbar-width property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported in some modern browsers, but not all.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!