Support0

CSS scrollbar

Explore scrollbar-color, scrollbar-width, and scrollbar-gutter with a preview that forces vertical scrolling and generates copy-ready CSS.

Ask AI

CSS scrollbar

Response generated with openai/gpt-5.4-nano. AI can make mistakes. Always review the result.

This block forces vertical scrolling so you can inspect the scrollbar while changing its properties.

scrollbar-color sets the thumb and track colors with the standard CSS syntax.

scrollbar-width switches between auto, thin, and none without relying on proprietary pseudo-elements.

scrollbar-gutter reserves space for the scrollbar and helps prevent content shifts when scrolling appears.

HTML
<div class="scrollbar-demo">
  <p>
    Scrollbars are part of the interface. Use this content block to test
    scrollbar-color, scrollbar-width, and scrollbar-gutter while the element
    keeps enough text to overflow vertically.
  </p>
  <p>
    Add real content here and check how the reserved gutter changes the
    reading area when the scrollbar is visible.
  </p>
</div>
Tailwind CSS
Examples for Tailwind CSS 4.3 with the default theme. Custom values keep arbitrary classes when there is no equivalent utility. Changing the theme can change utility values.
<div class="block-12 overflow-y-scroll scrollbar-thumb-[#38d5b2] scrollbar-track-[#232946] scrollbar-thin scrollbar-gutter-stable">
  <p>
    Scrollbars are part of the interface. Use this content block to test
    scrollbar-color, scrollbar-width, and scrollbar-gutter while the element
    keeps enough text to overflow vertically.
  </p>
  <p>
    Add real content here and check how the reserved gutter changes the
    reading area when the scrollbar is visible.
  </p>
</div>
CSS
.scrollbar-demo {
  block-size: 3rem;
  overflow-y: scroll;
  scrollbar-color: #38d5b2 #232946;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

Educational guide to scrollbar

Style the scrollbar while keeping scrolling usable

Separate color, thickness, and reserved space. Try native scrollbars while preserving keyboard access, contrast, and platform preferences.

Mental model

The scrollbar is a native interface on a scrolling container.

Start with overflow and content that overflows. scrollbar-color and scrollbar-width change the scrollbar’s presentation; scrollbar-gutter controls whether space is reserved for it. None creates content, enables snap, or replaces overflow. Apply the properties to the element that scrolls.

  1. Thumb: moving part

    Represents the position and lets you drag through the content.

  2. Track: rail

    The surface along which the thumb moves.

  3. Gutter: reservation

    The space a classic scrollbar occupies beside the content.

Color, thickness, and space are separate decisionsStatic diagram, not to scale. An overlay scrollbar is drawn over the content and takes up no gutter. The following examples use the browser’s real scrollbars.

Thumb and track colors

Two colors in that order, or auto to keep the platform’s choice.

scrollbar-color: thumb track accepts two colors, not just one. It is inherited: an ancestor’s change can reach other panels. This recipe scopes it to the scrollport and keeps auto as the base. Local variables separate the colors and light-dark() follows the inherited color-scheme; configure the light/dark scheme on the document using the recipe.

Local colors on a native scrollbar

Start of the reading. Focus this region to move through its content with the keyboard.

Middle section. The scrollbar reflects the position within overflowing content.

End of the reading. Tab continues to the next element on the page.

Scroll the content to see the thumb. The color pair follows the document’s scheme; the system may hide an idle scrollbar or render the track differently.
Local colors on a native scrollbar
<div class="scrollbar-guide-colors">
  <div class="scroller" role="region" aria-label="Scrollable reading example" tabindex="0">
    <div class="reading">
      <p>Start of the reading. Focus this region to move through its content with the keyboard.</p>
      <p>Middle section. The scrollbar reflects the position within overflowing content.</p>
      <p>End of the reading. Tab continues to the next element on the page.</p>
    </div>
  </div>
</div>
.scrollbar-guide-colors {
  color-scheme: inherit;

  .scroller {
    box-sizing: border-box;
    min-inline-size: 0;
    block-size: 12rem;
    overflow: auto;
    padding: 0.5rem;
    border: 1px solid currentColor;
    scrollbar-color: auto;
    scrollbar-width: auto;
    scrollbar-gutter: auto;

    &:focus-visible {
      outline: 3px solid currentColor;
      outline-offset: 2px;
    }

    @supports (scrollbar-color: auto) {
      --thumb: light-dark(#475569, #94a3b8);
      --track: light-dark(#f1f5f9, #0f172a);

      scrollbar-color: var(--thumb) var(--track);
    }
  }

  .reading {
    display: grid;
    gap: 1rem;
    min-block-size: 24rem;
    overflow-wrap: anywhere;
  }

  p {
    margin: 0;
  }
}

Check at least 3:1 between thumb and track, plus visibility over content when the track is transparent or overlaid. A computed color does not prove how every system paints the scrollbar. Do not animate these colors or replace the scrollbar with a custom draggable element just for decoration.

Thickness without a fixed measurement

auto and thin are platform hints, not pixel widths.

scrollbar-width accepts auto, thin, or none, without lengths. auto keeps the platform’s thickness; thin requests a narrower variant and may look the same if the browser or preferences dictate it. It is not inherited. none hides the indicator while keeping the element scrollable: it is not equivalent to overflow: hidden and makes scrolling harder to discover or drag.

Compare auto and thin without hiding the scrollbar

scrollbar-width: auto

Start of the reading. Focus this region to move through its content with the keyboard.

Middle section. The scrollbar reflects the position within overflowing content.

End of the reading. Tab continues to the next element on the page.

scrollbar-width: thin

Start of the reading. Focus this region to move through its content with the keyboard.

Middle section. The scrollbar reflects the position within overflowing content.

End of the reading. Tab continues to the next element on the page.

Both regions remain scrollable and focusable. The thin variant returns to auto if any coarse pointer is available or forced colors are active. Some platforms may show no visible thickness difference.
Compare auto and thin without hiding the scrollbar
<div class="scrollbar-guide-width">
  <div>
    <strong>scrollbar-width: auto</strong>
  <div class="scroller auto" role="region" aria-label="Scrollable reading example" tabindex="0">
    <div class="reading">
      <p>Start of the reading. Focus this region to move through its content with the keyboard.</p>
      <p>Middle section. The scrollbar reflects the position within overflowing content.</p>
      <p>End of the reading. Tab continues to the next element on the page.</p>
    </div>
  </div>
  </div>
  <div>
    <strong>scrollbar-width: thin</strong>
  <div class="scroller thin" role="region" aria-label="Scrollable reading example" tabindex="0">
    <div class="reading">
      <p>Start of the reading. Focus this region to move through its content with the keyboard.</p>
      <p>Middle section. The scrollbar reflects the position within overflowing content.</p>
      <p>End of the reading. Tab continues to the next element on the page.</p>
    </div>
  </div>
  </div>
</div>
.scrollbar-guide-width {
  display: grid;
  gap: 1rem;

  .scroller {
    box-sizing: border-box;
    min-inline-size: 0;
    block-size: 12rem;
    overflow: auto;
    padding: 0.5rem;
    border: 1px solid currentColor;
    scrollbar-color: auto;
    scrollbar-width: auto;
    scrollbar-gutter: auto;

    &:focus-visible {
      outline: 3px solid currentColor;
      outline-offset: 2px;
    }
  }

  .thin {
    scrollbar-width: thin;

    @media (any-pointer: coarse), (forced-colors: active) {
      scrollbar-width: auto;
    }
  }

  .reading {
    display: grid;
    gap: 1rem;
    min-block-size: 24rem;
    overflow-wrap: anywhere;
  }

  p {
    margin: 0;
  }
}

Prefer auto for content people need to scroll manually. A wheel or swipe is not available on every device. The playground lets you explore none; this guide does not offer it as a general recipe. Do not set padding on the assumption that a scrollbar always measures 15px.

Reserve space and understand overlay scrollbars

stable avoids width changes with classic scrollbars without forcing one to appear.

With classic scrollbars and overflow: auto, auto reserves space only when content overflows; stable reserves it even without overflow. stable both-edges adds a matching gutter on the opposite inline edge. It does not create a second scrollbar or reserve all four sides. Overlay scrollbars reserve no gutter, even with stable: the browser and system choose the model.

The same content with auto, stable, and stable both-edges

scrollbar-gutter: auto

Short content

scrollbar-gutter: stable

Short content

scrollbar-gutter: stable both-edges

Short content

Check the box to lengthen all three panels. Dashed lines mark the content: with classic scrollbars, auto loses width when the scrollbar appears while the others retain their reservation. With overlays they may look identical. Enlarged text may also overflow in the short state.
The same content with auto, stable, and stable both-edges
<div class="scrollbar-guide-gutter">
  <label><input type="checkbox"> Add content to cause overflow</label>
  <div>
    <strong>scrollbar-gutter: auto</strong>
    <div class="scroller gutter-0" role="region" aria-label="Scrollable reading example — auto" tabindex="0">
      <p>Short content</p>
    </div>
  </div>
  <div>
    <strong>scrollbar-gutter: stable</strong>
    <div class="scroller gutter-1" role="region" aria-label="Scrollable reading example — stable" tabindex="0">
      <p>Short content</p>
    </div>
  </div>
  <div>
    <strong>scrollbar-gutter: stable both-edges</strong>
    <div class="scroller gutter-2" role="region" aria-label="Scrollable reading example — stable both-edges" tabindex="0">
      <p>Short content</p>
    </div>
  </div>
</div>
.scrollbar-guide-gutter {
  display: grid;
  gap: 1rem;

  label {
    overflow-wrap: anywhere;
  }

  .scroller {
    box-sizing: border-box;
    min-inline-size: 0;
    block-size: 12rem;
    overflow: auto;
    padding: 0.5rem;
    border: 1px solid currentColor;
    scrollbar-color: auto;
    scrollbar-width: auto;
    scrollbar-gutter: auto;

    &:focus-visible {
      outline: 3px solid currentColor;
      outline-offset: 2px;
    }
  }

  .gutter-1 {
    scrollbar-gutter: stable;
  }

  .gutter-2 {
    scrollbar-gutter: stable both-edges;
  }

  p {
    margin: 0;
    border-inline: 1px dashed currentColor;
    overflow-wrap: anywhere;
  }

  &:has(input:checked) .scroller p {
    min-block-size: 24rem;
  }
}

An empty gutter is painted as an extension of padding. stable is neither permanent padding nor scroll-padding: the latter adjusts the alignment region for navigation or snap. For the viewport, declare scrollbar-gutter on html; it does not propagate from body. Do not simulate a gutter on systems that overlay scrollbars.

Keyboard and contrast preferences

The region has its own focus and lets system colors take effect.

tabindex="0" makes the panel focusable for keyboard scrolling. role="region" and a name identify it; reserve this pattern for areas that deserve a focus stop rather than turning every box into a region. The recipe keeps a visible outline. prefers-contrast: more strengthens the color pair; forced-colors: active restores auto and allows native adaptation, without forced-color-adjust: none.

A named region with focus and adaptive contrast

Focus the panel with Tab and scroll with the arrow keys or Page Down.

Start of the reading. Focus this region to move through its content with the keyboard.

Middle section. The scrollbar reflects the position within overflowing content.

End of the reading. Tab continues to the next element on the page.

Use Tab to enter and leave; with the region focused, try the arrow keys or Page Down. The outline identifies focus. In forced colors, the system chooses scrollbar colors and preserves the border.
A named region with focus and adaptive contrast
<div class="scrollbar-guide-access">
  <p id="scrollbar-keyboard-hint">Focus the panel with Tab and scroll with the arrow keys or Page Down.</p>
  <div class="scroller" role="region" aria-label="Scrollable reading example" aria-describedby="scrollbar-keyboard-hint" tabindex="0">
    <div class="reading">
      <p>Start of the reading. Focus this region to move through its content with the keyboard.</p>
      <p>Middle section. The scrollbar reflects the position within overflowing content.</p>
      <p>End of the reading. Tab continues to the next element on the page.</p>
    </div>
  </div>
</div>
.scrollbar-guide-access {
  color-scheme: inherit;

  .scroller {
    box-sizing: border-box;
    min-inline-size: 0;
    block-size: 12rem;
    overflow: auto;
    padding: 0.5rem;
    border: 1px solid currentColor;
    scrollbar-color: auto;
    scrollbar-width: auto;
    scrollbar-gutter: auto;

    &:focus-visible {
      outline: 3px solid currentColor;
      outline-offset: 2px;
    }

    @supports (scrollbar-color: auto) {
      --thumb: light-dark(#475569, #94a3b8);
      --track: light-dark(#f1f5f9, #0f172a);

      scrollbar-color: var(--thumb) var(--track);

      @media (prefers-contrast: more) {
        --thumb: light-dark(#000000, #ffffff);
        --track: light-dark(#ffffff, #000000);
      }
    }

    @media (forced-colors: active) {
      scrollbar-color: auto;
      scrollbar-width: auto;
    }
  }

  .reading {
    display: grid;
    gap: 1rem;
    min-block-size: 24rem;
    overflow-wrap: anywhere;
  }

  p {
    margin: 0;
  }
}

forced-colors and prefers-contrast are different preferences. Do not force black and white inside a system palette. The native scrollbar remains the fallback when styles are ignored; preserve content, keyboard access, and testing on real devices.

Common pitfalls

Separate ignored styling, system preferences, and missing overflow.

No scrollbar appears

Expected result
See the indicator and move through the content.
Cause
Content does not overflow, overflow prevents manual scrolling, none was applied, or the system hides idle scrollbars.
Solution
Check sizing and overflow on the actual scrollport, use auto, and scroll or hover over the panel. Check the system’s scrollbar preferences.

stable does not leave the expected gap

Expected result
Always reserve an identical strip beside the content.
Cause
Overlay scrollbars take up no gutter; stable neither defines a fixed width nor chooses the scrollbar model.
Solution
Test classic scrollbars too. Use padding for permanent design space and avoid measuring a scrollbar to simulate the reservation.

The scrollbar becomes hard to see in another environment

Expected result
Distinguish and use the scrollbar in both themes and high contrast.
Cause
The thumb relies on a transparent track, styling is inherited unexpectedly, or the system palette was blocked.
Solution
Scope scrollbar-color, check the actual background and both themes, and preserve auto in forced colors. Check keyboard focus and scrolling.

Support and compatibility

Each of the three properties has its own support history.

As checked on October 28, 2026, Web Platform DX classifies scrollbar-width and scrollbar-gutter as Baseline Newly available since December 11, 2024, and scrollbar-color since December 12, 2025. This is not yet Widely available and does not promise identical rendering across systems. Styling is progressive enhancement: without support the native scrollbar remains. The ::-webkit-scrollbar pseudo-elements are nonstandard and are unnecessary for these examples’ fallback. @supports checks syntax, not the classic/overlay model or final visibility.