CSS scrollbar-width Property

The CSS scrollbar-width property controls the thickness of a scrollbar or hides its visual appearance without disabling scrolling.

It provides three values: auto, thin, and none. The browser determines the actual scrollbar dimensions, so the property cannot specify an exact width in pixels. It works with native scrollbars in both vertical and horizontal scrolling containers.

scrollbar-width Syntax

The scrollbar-width property accepts one keyword that determines the requested scrollbar thickness.

Basic Syntax

selector {
  scrollbar-width: thin;
}

Available Values

.container {
  scrollbar-width: auto;
}
.container {
  scrollbar-width: thin;
}
.container {
  scrollbar-width: none;
}

CSS-Wide Keywords

.container {
  scrollbar-width: initial;
}
.container {
  scrollbar-width: inherit;
}
.container {
  scrollbar-width: unset;
}
.container {
  scrollbar-width: revert;
}
.container {
  scrollbar-width: revert-layer;
}

Unlike the CSS width property, scrollbar-width does not accept length values such as 8px or 1rem.

Property Values

Value Description
auto Uses the browser's default scrollbar thickness. This is the initial value.
thin Requests a thinner scrollbar than the default, when supported by the browser and platform.
none Hides the visual scrollbar while preserving the element's scrolling functionality.
initial Resets the property to auto.
inherit Uses the computed value from the parent element.
unset Resets the property to auto because it is not inherited.
revert Reverts the property according to CSS cascade origin rules.
revert-layer Reverts the property according to CSS cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to Scrolling boxes
Computed value As specified
Animation type Discrete
Percentages Not applicable
Related properties scrollbar-color, scrollbar-gutter
Specification CSS Scrollbars Styling Module Level 1

Valid Values

.container {
  scrollbar-width: auto;
}
.container {
  scrollbar-width: thin;
}
.container {
  scrollbar-width: none;
}
.container {
  scrollbar-width: initial;
}
.container {
  scrollbar-width: inherit;
}

Invalid Values

.container {
  scrollbar-width: 10px;
}
.container {
  scrollbar-width: 1rem;
}
.container {
  scrollbar-width: thick;
}
.container {
  scrollbar-width: hidden;
}
.container {
  scrollbar-width: auto thin;
}
.container {
  scrollbar-width: 50%;
}

The property accepts only the defined keywords and CSS-wide keywords. Custom pixel dimensions, percentages, and the keyword hidden are not supported.

How It Works

Browsers normally display scrollbars using dimensions determined by the operating system and browser settings. The scrollbar-width property requests a standard, thinner, or visually hidden scrollbar.

Step 1: Create a Scroll Container

.scroll-panel {
  height: 200px;
  overflow-y: auto;
}

The browser displays a scrollbar when the content exceeds the available height, subject to platform scrollbar settings.

Step 2: Choose the Scrollbar Width

.scroll-panel {
  scrollbar-width: thin;
}

The browser requests a thinner native scrollbar.

Step 3: Scroll the Content

The element continues to scroll normally. The property changes the scrollbar's visual presentation rather than the scrolling behavior.

Default Behavior

.scroll-panel {
  scrollbar-width: auto;
}

The browser uses its normal scrollbar thickness.

Scrollbar Visibility

The none value hides the scrollbar itself but does not automatically disable wheel, touch, keyboard, or programmatic scrolling.

Important Consideration

The actual thickness of auto and thin is controlled by the browser and operating system. The property does not guarantee a specific pixel measurement.

The auto Value

The auto value allows the browser or operating system to determine the scrollbar's normal thickness.

Basic Example

.scroll-panel {
  overflow-y: auto;
  scrollbar-width: auto;
}

Default Appearance

The scrollbar uses the browser's standard dimensions, which may vary by operating system, theme, and user preferences.

Traditional Scrollbars

Traditional scrollbars occupy space beside or below the scrollable content.

Overlay Scrollbars

Overlay scrollbars appear over content and may remain hidden until scrolling occurs.

When to Use auto

Use auto when native scrollbar appearance and discoverability are preferred.

Important Consideration

The auto value generally provides the most familiar scrollbar experience for users because it follows platform conventions.

The thin Value

The thin value requests a scrollbar that is thinner than the browser's standard scrollbar.

Basic Example

.scroll-panel {
  overflow-y: auto;
  scrollbar-width: thin;
}

Compact Scroll Containers

.sidebar {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
}

Thin scrollbars can reduce the visual prominence of scrolling controls in compact layouts.

Horizontal Scrollbars

.horizontal-list {
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
}

The property also applies to horizontal scrollbars. It requests a thinner scrollbar rather than a narrower scrollable element.

Combining With Custom Colors

.scroll-panel {
  scrollbar-width: thin;
  scrollbar-color: #2563eb #e2e8f0;
}

The browser requests a thin scrollbar with a blue thumb and light gray track.

No Exact Pixel Width

The browser chooses how thin the scrollbar becomes. The result may differ across operating systems.

Important Consideration

Thin scrollbars can be harder to operate with a mouse or other pointing device. Avoid using them where users frequently need to drag the scrollbar thumb.

The none Value

The none value hides the visual scrollbar while allowing the content to remain scrollable.

Basic Example

.scroll-panel {
  height: 200px;
  overflow-y: auto;
  scrollbar-width: none;
}

Scrolling Still Works

Users may still scroll using a mouse wheel, touch gesture, keyboard, or other supported input method.

Horizontal Scrolling

.horizontal-gallery {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

The horizontal scrollbar is hidden, but the gallery can still scroll.

Difference Between none and overflow: hidden

Declaration Effect
scrollbar-width: none; Hides the scrollbar while preserving scrolling behavior.
overflow: hidden; Clips overflowing content and prevents normal user scrolling, although programmatic scrolling may remain possible.

Providing Alternative Controls

If a scrollbar is hidden, consider providing visible navigation buttons, scroll indicators, or other controls that make additional content discoverable.

Important Consideration

Hiding scrollbars can make content difficult to discover or navigate. Avoid scrollbar-width: none for ordinary text containers and essential navigation areas.

Styling Scroll Containers

The scrollbar-width property can be applied to independently scrolling elements.

Vertical Scroll Container

.vertical-panel {
  height: 250px;
  overflow-y: auto;
  scrollbar-width: thin;
}

Horizontal Scroll Container

.horizontal-panel {
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
}

Both Scrolling Directions

.scroll-grid {
  width: 400px;
  height: 250px;
  overflow: auto;
  scrollbar-width: thin;
}

When both vertical and horizontal scrollbars appear, the property requests the same thickness category for both.

Nested Scroll Containers

.outer-panel {
  overflow: auto;
  scrollbar-width: auto;
}
.inner-panel {
  overflow: auto;
  scrollbar-width: thin;
}

Each scroll container can use a different value because the property is not inherited.

Resetting a Scroll Container

.inner-panel {
  scrollbar-width: auto;
}

This restores the browser's default scrollbar thickness for the inner container.

Important Consideration

The property does not create scrollable overflow. A scrollbar appears only when the element's overflow behavior and content require or permit one.

Styling the Page Scrollbar

The scrollbar-width property can control the scrollbar used for the document viewport.

Thin Viewport Scrollbar

html {
  scrollbar-width: thin;
}

Applying the property to the root element causes its value to be propagated to the viewport scrollbar.

Default Viewport Scrollbar

html {
  scrollbar-width: auto;
}

Hidden Viewport Scrollbar

html {
  scrollbar-width: none;
}

This hides the viewport scrollbar in supporting browsers. It is generally discouraged because users may not realize that the page can scroll.

Body vs. Root Element

body {
  scrollbar-width: thin;
}

Applying the property to body does not provide the same specified viewport propagation as applying it to html.

Recommended Approach

html {
  scrollbar-width: auto;
}
.sidebar {
  scrollbar-width: thin;
}

Keep the main page scrollbar at its default thickness while using thinner scrollbars selectively in smaller components.

Important Consideration

Viewport scrollbar visibility and appearance remain subject to browser and operating system settings.

Three standard CSS properties control different aspects of native scrollbar appearance and layout.

Property Purpose
scrollbar-width Controls the requested scrollbar thickness or hides the scrollbar.
scrollbar-color Specifies scrollbar thumb and track colors.
scrollbar-gutter Controls whether space is reserved for traditional scrollbars.

Thin Scrollbar With Custom Colors

.scroll-panel {
  scrollbar-width: thin;
  scrollbar-color: #2563eb #e2e8f0;
}

Thin Scrollbar With Stable Gutter

.scroll-panel {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

The browser requests a thin scrollbar and reserves traditional scrollbar gutter space when applicable.

Combining All Three Properties

.scroll-panel {
  height: 250px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2563eb #e2e8f0;
  scrollbar-gutter: stable;
}

This combination controls scrollbar thickness, colors, and gutter reservation.

Important Consideration

Scrollbar properties do not override every operating system setting. Their appearance may differ across platforms.

Browser and System Appearance

Native scrollbar rendering depends on the browser, operating system, and user preferences.

Traditional Scrollbars

Traditional scrollbars occupy space alongside the scrollable content. A thinner scrollbar may reduce the space it consumes.

Overlay Scrollbars

Overlay scrollbars appear over content and may be hidden until scrolling occurs. Their visual thickness can vary with platform behavior.

Operating System Preferences

Some operating systems allow users to control scrollbar visibility or appearance. CSS should not be used to defeat these preferences.

Touch Devices

On touch devices, scrollbars may appear only temporarily during scrolling. The visual difference between auto and thin may be small or difficult to observe.

High Contrast Settings

System accessibility settings may affect scrollbar appearance. Test custom scrollbar styling with high contrast and other accessibility modes.

Standard and Vendor-Specific Styling

Older implementations may use vendor-specific scrollbar pseudo-elements. The standardized scrollbar-width property provides a simpler way to request scrollbar thickness.

Important Consideration

Do not rely on exact scrollbar dimensions for critical layout measurements. Native scrollbars are controlled partly by the user's environment.

Practical Examples

Default Scrollbar

.scroll-panel {
  scrollbar-width: auto;
}

Uses the browser's standard scrollbar thickness.

Thin Sidebar Scrollbar

.sidebar {
  max-height: 70vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

Requests a thinner scrollbar for a compact sidebar.

Thin Code Example Scrollbar

.code-example {
  overflow-x: auto;
  scrollbar-width: thin;
}

Provides horizontal scrolling for long code lines with a thinner scrollbar.

Scrollable Data Table

.table-wrapper {
  max-height: 350px;
  overflow: auto;
  scrollbar-width: thin;
}

Requests thin scrollbars for a table container with overflowing content.

Custom Scrollbar Colors

.scroll-panel {
  scrollbar-width: thin;
  scrollbar-color: #1d4ed8 #dbeafe;
}

Combines a thin scrollbar with contrasting thumb and track colors.

Horizontal Gallery

.gallery {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  scrollbar-width: thin;
}

Provides a less prominent scrollbar for a horizontally scrolling gallery.

Responsive Scrollbar Styling

.scroll-panel {
  scrollbar-width: auto;
}
@media (min-width: 992px) {
  .scroll-panel {
    scrollbar-width: thin;
  }
}

Uses the default scrollbar on smaller screens and requests a thinner scrollbar on larger screens.

Restoring Default Thickness

.scroll-panel {
  scrollbar-width: auto;
}

Returns the scrollbar to the browser's default thickness.

scrollbar-width Example

This interactive example compares the three scrollbar-width values. Scroll inside each panel to observe the differences between the default, thin, and hidden scrollbars.

HTML Example

<div class="scrollbar-width-demo">
  <div class="scroll-panel auto" tabindex="0">
    <h3>auto</h3>
    <p>Scroll to see more content.</p>
    <p>The scrollbar uses its default thickness.</p>
    <p>Scrolling remains available.</p>
    <p>End of the panel.</p>
  </div>
  <div class="scroll-panel thin" tabindex="0">
    <h3>thin</h3>
    <p>Scroll to see more content.</p>
    <p>The scrollbar requests a thinner appearance.</p>
    <p>Scrolling remains available.</p>
    <p>End of the panel.</p>
  </div>
  <div class="scroll-panel none" tabindex="0">
    <h3>none</h3>
    <p>Scroll to see more content.</p>
    <p>The scrollbar is hidden.</p>
    <p>Scrolling remains available.</p>
    <p>End of the panel.</p>
  </div>
</div>

CSS Example

.scrollbar-width-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 15px;
}
.scrollbar-width-demo .scroll-panel {
  height: 180px;
  overflow-y: auto;
  padding: 15px;
  border: 1px solid #94a3b8;
  background-color: #f8fafc;
}
.scrollbar-width-demo .scroll-panel h3 {
  margin-top: 0;
  font-size: 1rem;
}
.scrollbar-width-demo .scroll-panel p {
  margin-bottom: 35px;
}
.scrollbar-width-demo .auto {
  scrollbar-width: auto;
}
.scrollbar-width-demo .thin {
  scrollbar-width: thin;
}
.scrollbar-width-demo .none {
  scrollbar-width: none;
}
Browser Result

auto

Scroll to see more content.

The scrollbar uses its default thickness.

Scrolling remains available.

End of the panel.

thin

Scroll to see more content.

The scrollbar requests a thinner appearance.

Scrolling remains available.

End of the panel.

none

Scroll to see more content.

The scrollbar is hidden.

Scrolling remains available.

End of the panel.

The first panel uses the browser's default scrollbar thickness. The second requests a thinner scrollbar. The third hides the scrollbar while keeping the content scrollable.

Comparing the Values

Value Visual Result Scrolling
auto Default scrollbar thickness Available
thin Thinner scrollbar when supported Available
none Scrollbar hidden Available

Changing the Thin Scrollbar

.scrollbar-width-demo .thin {
  scrollbar-width: auto;
}

The second panel returns to the browser's default scrollbar thickness.

Adding Custom Colors

.scrollbar-width-demo .thin {
  scrollbar-width: thin;
  scrollbar-color: #2563eb #dbeafe;
}

The second panel requests a thin scrollbar with a blue thumb and light blue track.

Restoring the Hidden Scrollbar

.scrollbar-width-demo .none {
  scrollbar-width: auto;
}

The third panel displays its scrollbar according to the browser's default behavior.

Browser Compatibility Note

The appearance of auto and thin may differ between browsers and operating systems. Overlay scrollbars may remain hidden until scrolling occurs.

Accessibility Considerations

Scrollbars provide a visual indication that additional content is available and offer a direct way to navigate it.

Prefer Visible Scrollbars

For most scrolling containers, visible scrollbars make content easier to discover and navigate.

Avoid Hiding Essential Scrollbars

The none value can make scrollable content difficult to recognize, especially for users who do not use touch gestures or mouse wheels.

Consider Pointer Target Size

Thin scrollbars may provide a smaller target for users who drag the scrollbar thumb with a mouse or other pointing device.

Preserve Keyboard Access

Scrollable regions should remain accessible to keyboard users. For independently scrollable regions that are not otherwise keyboard-focusable, a suitable tabindex may be necessary.

Provide Alternative Navigation

If hiding a scrollbar is necessary, provide clear controls or indicators that show users how to reach additional content.

Respect Operating System Preferences

Users may configure scrollbar visibility or appearance through their operating system. Avoid unnecessarily overriding these preferences.

Maintain Color Contrast

When combining scrollbar-width with scrollbar-color, choose colors that make the scrollbar thumb distinguishable from its track.

Test Different Input Methods

Verify scrolling with a keyboard, mouse, touch screen, and other supported input methods.

Common Mistakes

Using Pixel Values

.container {
  scrollbar-width: 8px;
}

The property does not accept custom pixel dimensions.

Using the hidden Keyword

.container {
  scrollbar-width: hidden;
}

Use none to hide the scrollbar.

Using Multiple Values

.container {
  scrollbar-width: auto thin;
}

Only one value can be specified.

Expecting an Exact Thin Width

The thin keyword does not represent a fixed number of pixels.

Confusing none With overflow: hidden

The none value hides the scrollbar but preserves scrolling. The overflow: hidden declaration prevents normal user scrolling.

Expecting a Scrollbar Without Overflow

The property does not create overflowing content or force scrollbars to appear.

Applying the Property Only to body

Use the root html element when styling the viewport scrollbar.

Assuming Inheritance

The property is not inherited. Descendant scroll containers need their own declarations.

Hiding Scrollbars Without Alternatives

Users may not recognize that content can scroll when its scrollbar is hidden.

Ignoring Platform Differences

Native scrollbar thickness and visibility vary between browsers and operating systems.

Confusing Width and Color

The scrollbar-width property does not change scrollbar colors. Use scrollbar-color for that purpose.

Confusing Width and Gutter Space

The scrollbar-gutter property controls reserved scrollbar space, not the scrollbar's thickness category.

Important Considerations

Keep the following points in mind when using scrollbar-width:

  • It controls the requested thickness or visibility of native scrollbars.
  • The initial value is auto.
  • The property is not inherited.
  • The valid values are auto, thin, and none.
  • The auto value uses the browser's default scrollbar thickness.
  • The thin value requests a thinner scrollbar.
  • The none value hides the scrollbar while preserving scrolling.
  • The property does not accept pixel lengths or percentages.
  • The actual scrollbar thickness depends on the browser and operating system.
  • It applies to vertical and horizontal scrollbars.
  • It does not create a scroll container.
  • Scrollbar visibility also depends on overflow settings.
  • Overlay scrollbars may appear only while scrolling.
  • Use the root html element to style the viewport scrollbar.
  • Descendant scroll containers do not automatically inherit the value.
  • Thin scrollbars may be harder to operate with a pointing device.
  • Hidden scrollbars can make additional content difficult to discover.
  • Use scrollbar-color to customize thumb and track colors.
  • Use scrollbar-gutter to control reserved scrollbar space.
  • Test scrollbar styling across browsers, operating systems, and input methods.

Browser Support

The CSS scrollbar-width property is widely available in modern browsers, including current versions of Chrome, Edge, Firefox, and Safari.

Although support is broad, the exact appearance of auto and thin varies according to browser and operating system scrollbar conventions.

For current compatibility information, visit Can I Use? and search for scrollbar-width.

Feature Detection

@supports (scrollbar-width: thin) {
  .scroll-panel {
    scrollbar-width: thin;
  }
}

Feature queries allow thin scrollbar styling to be applied only when the browser recognizes the property.

Fallback Behavior

When unsupported, the browser uses its default scrollbar appearance. Scrolling continues to function according to the element's overflow settings.

Standard and Vendor-Specific Styling

Some older browser implementations use vendor-specific scrollbar pseudo-elements. When a supporting browser uses scrollbar-width with a value other than auto, the standardized property can override corresponding ::-webkit-scrollbar-* styling.

Testing Recommendations

Check both traditional and overlay scrollbar environments, particularly when using thin or none.

Specifications

The scrollbar-width property is defined in the CSS Scrollbars Styling Module Level 1 specification.

CSS Scrollbars Styling Module Level 1

The specification defines the auto, thin, and none values for controlling native scrollbar thickness and visibility.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: scrollbar-width