CSS scrollbar-color Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The scrollbar-color property sets the color of a scrollbar’s thumb (the moving piece) and track (the background groove).

Apply it to a scrolling box — typically one with overflow: auto or scroll. On the root element (html) it styles the viewport scrollbar. The property is inherited. The initial value is auto.

Baseline 2025 · Newly available.

Not deprecated. Cross-browser support is recent (Safari joined in late 2025). Treat custom colors as progressive enhancement; keep usable defaults when unsupported.

CSS Syntax

syntax.css
scrollbar-color: auto | <color> <color>;

Example: scrollbar-color: #2563eb #e2e8f0; — first color = thumb, second = track.

Property Values

ValueDescriptionTry it
autoPlatform default colors. Initial valueTry it
Two <color>sThumb color, then track colorTry it
initialResets to autoTry it
inheritTakes the parent’s scrollbar-colorTry it

Pick thumb and track colors with enough contrast (about 3:1) so the scrollbar stays easy to see.

How to Use scrollbar-color

Make a scrolling box, then set thumb and track colors on that box.

  1. Create a scroll container with a fixed height and overflow: auto (or scroll).
  2. Set scrollbar-color to two colors: thumb first, track second.
  3. Optional: pair with scrollbar-width to thin the bar.
  4. Check contrast, and remember overlay scrollbars (common on macOS) may hide the track until hover.
PieceRequired?Role
Scrolling boxYesOverflow that scrolls, or html for the viewport
auto or two colorsYesDefault look, or thumb + track
ContrastRecommendedThumb and track should remain distinct

Live Preview

Scroll the box and switch scrollbar-color. You need enough content for a scrollbar to appear.

First color = thumb. Second = track. Overlay OS scrollbars may show the track only on hover.

Scroll box

Line 1 — scroll to see the colored bar.

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

Line 9

Line 10

scrollbar-color: #2563eb #e2e8f0

CSS Examples

Each snippet focuses on scrollbar-color. Extra styles stay minimal for study. Use Try It Yourself for a live editor.

Example 1 — Thumb and Track Colors

Color the draggable thumb and the track behind it.

CSS
<style>
  .box {
    height: 120px;
    overflow: auto;
    scrollbar-color: #2563eb #e2e8f0;
  }
</style>

<div class="box">
  <p>One</p><p>Two</p><p>Three</p>
  <p>Four</p><p>Five</p><p>Six</p>
</div>
Try It Yourself

How It Works

  1. Make it scroll. Fixed height plus overflow: auto shows a scrollbar when needed.
  2. Two colors. First (#2563eb) paints the thumb; second (#e2e8f0) paints the track.
  3. Scroll to see it. Move the bar to confirm both parts are visible.
  4. Standard property. Prefer this over non-standard ::-webkit-scrollbar when you can.

Example 2 — Platform Default

Use auto to keep the operating system scrollbar look.

CSS
<style>
  .box {
    height: 120px;
    overflow: auto;
    scrollbar-color: auto;
  }
</style>

<div class="box">
  <p>One</p><p>Two</p><p>Three</p>
  <p>Four</p><p>Five</p><p>Six</p>
</div>
Try It Yourself

How It Works

  1. Default keyword. auto is the initial value.
  2. OS decides. Colors follow platform conventions (and may respect light/dark UI).
  3. Restores WebKit styles. Setting auto allows ::-webkit-scrollbar-* rules again if an ancestor had forced colors.
  4. Safe fallback. Use auto when you want no custom theme.

Example 3 — Match a Dark Panel

Pick light thumb and dark track colors for a dark scroll box.

CSS
<style>
  .box {
    height: 120px;
    overflow: auto;
    background: #0f172a;
    color: #e2e8f0;
    scrollbar-color: #94a3b8 #1e293b;
  }
</style>

<div class="box">
  <p>One</p><p>Two</p><p>Three</p>
  <p>Four</p><p>Five</p><p>Six</p>
</div>
Try It Yourself

How It Works

  1. Theme the box. Dark background sets the context for the scrollbar.
  2. Match the bar. Light thumb on a darker track keeps the control readable.
  3. Check contrast. Thumb and track should not blend into each other.
  4. Progressive. Unsupported browsers keep their default scrollbar.

Edge Cases & Pitfalls

If the scrollbar looks wrong or unchanged, one of these is usually why.

order

Thumb first, track second

Two colors are required. Swapping them paints the groove with the thumb color.

webkit

Non-auto disables ::-webkit-scrollbar

A non-auto value (including an inherited one) makes browsers ignore WebKit scrollbar pseudo-elements on that element.

overlay

Overlay scrollbars hide the track

On some OS settings the track is transparent until you hover the scrollbar. Thumb color still applies.

root

Viewport needs html, not only body

Root styles apply to the viewport. A body-only rule does not propagate there.

a11y

Forced colors may reset you

In forced-colors mode, user agents set scrollbar-color to auto so system contrast wins.

Browser Support

scrollbar-color is a browser CSS property for scroll containers. Node.js, Deno, and Bun do not apply it.

✓ Baseline 2025 · Newly available

scrollbar-color

Chrome 121+, Edge 121+, Firefox 64+, Safari 26.2+ / iOS 26.2+. Not supported in Internet Explorer.

88% Global support
Google Chrome 121+
Full support
Mozilla Firefox 64+
Full support
Apple Safari 26.2+
Full support
Microsoft Edge 121+
Full support
Opera 107+
Full support
Samsung Internet 25+
Full support
Internet Explorer No support
No support
scrollbar-color Newly available

Bottom line: Use as progressive enhancement. Older Safari and Chrome need a fallback or accept the default scrollbar. This is not a JavaScript runtime API.

Key Takeaways

  • Role: color the scrollbar thumb (first) and track (second), or use auto.
  • Inherited. Put it on the scrolling box (or html for the page).
  • Standard path for themed bars; non-auto turns off WebKit scrollbar pseudos.
  • Newly available. Keep contrast high; treat styling as progressive enhancement.

One line: scrollbar-color: thumb track themes the bar without WebKit-only CSS.

Frequently Asked Questions

It sets the colors of a scrollbar’s thumb (the draggable piece) and track (the groove behind it). Use two colors: first thumb, then track. Or use auto for the platform default.
The initial value is auto, which lets the browser and operating system choose the colors.
On a scrolling box — for example a div with overflow: auto or overflow: scroll. On the root (html) it styles the viewport scrollbar. A body-only rule does not apply to the viewport.
When scrollbar-color is anything other than auto, browsers ignore the non-standard ::-webkit-scrollbar family on that element (and on descendants that inherit the non-auto value).
Yes. A non-auto value on a parent can color scrollbars on nested scrollers unless they set their own value.
It is Baseline Newly available (2025): Chrome 121+, Edge 121+, Firefox 64+, Safari 26.2+. It is a browser CSS property, not a Node.js feature. Internet Explorer does not support it.

Next: tab-size

Control how wide tab characters render in preformatted text.

tab-size tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful