CSS scrollbar-color Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Scrollbar Styling

What You’ll Learn

The scrollbar-color property lets you customize scrollbar thumb and track colors on scrollable elements for a more polished, on-brand look.

01

thumb

Draggable.

02

track

Background.

03

auto

Default.

04

colors

Two values.

05

overflow

Scroll box.

06

width

Pair with it.

Introduction

The scrollbar-color property in CSS is a convenient way to customize the color of scrollbars in a web page.

It lets you specify the thumb and track colors, which helps scrollable areas feel more consistent with your site branding and overall design.

Definition and Usage

Apply scrollbar-color to elements that scroll — such as a content panel, sidebar, or card with overflow: auto or overflow: scroll.

The first color value styles the thumb. The second color value styles the track behind it.

💡
Beginner Tip

Try scrollbar-color: blue lightgray; on a scrollable div. The thumb becomes blue and the track becomes light gray in browsers that support the property.

📝 Syntax

The syntax for the scrollbar-color property is simple. You specify two colors: one for the thumb and one for the track.

syntax.css
element {
  scrollbar-color: thumb-color track-color;
}
  • thumb-color — the color of the scrollbar thumb
  • track-color — the color of the scrollbar track

Basic Example

scroll-box.css
.content-panel {
  overflow: auto;
  scrollbar-color: blue lightgray;
}

Related Properties

  • scrollbar-width — changes scrollbar thickness
  • overflow — makes an element scrollable
  • accent-color — themes native form controls

🎯 Default Value

The default value of the scrollbar-color property is auto, which means the browser and operating system choose the scrollbar colors.

⚡ Quick Reference

QuestionAnswer
Default valueauto
Common valuesblue lightgray, hex pairs, auto
Works withscrollbar-width and overflow
Accepted valuesauto or two color values
Set onScrollable elements with overflow
InheritedNo
AnimatableNo

💎 Property Values

ValueExampleDescription
autoscrollbar-color: auto;Uses the user agent’s default scrollbar colors.
thumb trackscrollbar-color: blue lightgray;Two color values for the thumb and track. Named colors, hex, rgb, and hsl are supported.
auto thumb track

When to Use scrollbar-color

scrollbar-color helps when scrollable areas should match your design system:

  • Content panels — Style scrollbars inside cards, modals, and docs sidebars.
  • Dashboard layouts — Keep scrollable widgets visually consistent with brand colors.
  • Dark mode themes — Use darker thumb and track colors in night-themed layouts.
  • Simple theming — Avoid long WebKit pseudo-element rules when standard colors are enough.

Use it on the scrolling element itself. For more advanced styling in unsupported browsers, you may still need ::-webkit-scrollbar rules.

👀 Live Preview

Scroll inside the box below. It uses scrollbar-color: #2563eb #e2e8f0.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam imperdiet est et risus convallis, ut accumsan magna tincidunt. Integer pulvinar dui non nisi elementum, a scelerisque nisl fermentum. Cras venenatis sem at velit auctor, nec lacinia lectus sodales. Duis convallis mi eu facilisis tristique.

In supporting browsers, the scrollbar thumb appears blue and the track appears light gray.

Examples Gallery

Start with the reference blue and light gray scrollbar, try brand hex colors, then explore dark theme and thin scrollbar styling.

📜 Custom Scrollbar Colors

Style scrollbar thumb and track colors on scrollable elements — matching the reference example.

Example 1 — Blue thumb and light gray track

In this example, we’ll change the scrollbar colors of a div element to have a blue thumb and a light gray track.

index.html
<style>
  div {
    width: 300px;
    height: 150px;
    overflow: auto;
    scrollbar-color: blue lightgray;
  }
</style>

<div>
  <p>Long scrollable content goes here...</p>
</div>
Try It Yourself

How It Works

The first color styles the thumb. The second color styles the track behind it.

Example 2 — Brand colors with hex values

Use hex colors to match your site palette on a scrollable notes panel.

brand-scrollbar.css
.notes-panel {
  overflow: auto;
  scrollbar-color: #7c3aed #ede9fe;
}
Try It Yourself

How It Works

Any valid CSS color format works for both values, including hex, rgb, hsl, and named colors.

📄 Theme Variations

Try dark scrollbars and pair color styling with scrollbar width controls.

Example 3 — Dark theme scrollbar

Use darker thumb and track colors in a night-mode sidebar or code panel.

dark-scrollbar.css
.dark-sidebar {
  overflow-y: auto;
  scrollbar-color: #94a3b8 #1e293b;
}
Try It Yourself

How It Works

Choose enough contrast between thumb and track so the scrollbar remains easy to see and use.

Example 4 — Thin scrollbar with custom colors

Pair scrollbar-color with scrollbar-width: thin for a sleeker scrollable panel.

thin-scrollbar.css
.compact-panel {
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #059669 #ecfdf5;
}
Try It Yourself

How It Works

Color and width are separate properties, but they work well together for lightweight panel designs.

scrollbar-color in the family

scrollbar-color styles the thumb and track on scrollable elements. Pair it with scrollbar-width when you also want a thinner or hidden scrollbar, and use overflow: auto or overflow: scroll so the element can actually scroll.

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

🧠 How scrollbar-color Works

1

Element must scroll

Apply overflow: auto or overflow: scroll so the browser shows a scrollbar when content overflows.

Overflow
2

You set two colors

Use scrollbar-color: thumb track; — the first color paints the draggable thumb, the second paints the track behind it.

CSS rule
3

Browser renders the scrollbar

In supporting browsers, the native scrollbar uses your colors. Use auto to fall back to the operating system defaults.

Rendering
=

Themed scrollbars

Scrollable panels, sidebars, and content boxes match your site palette without custom scrollbar pseudo-elements.

Browser Compatibility

The scrollbar-color property is well supported in Firefox and in Chromium browsers (Chrome, Edge, Opera) from version 121 onward. Safari support is still limited, especially on iOS where scrollbars are often overlay-style and may not show custom colors. Test scrollable panels in the browsers your audience uses.

Scrollbar styling · Modern support

Reliable in Firefox and Chromium

Firefox has supported scrollbar-color since version 64. Chrome, Edge, and Opera added support in 121+. Safari remains partial.

88% Modern browser support
Google Chrome 121+ · Desktop & Android
Full support
Mozilla Firefox 64+ · Desktop & Mobile
Full support
Apple Safari Limited · macOS & iOS
Partial support
Microsoft Edge 121+ · Chromium
Full support
Opera 107+ · Modern versions
Full support

Testing tip

Scroll a tall panel in Firefox and Chrome to confirm thumb and track colors. On iOS Safari, scrollbars may stay hidden until scrolling and may ignore custom colors.

scrollbar-color property 88% supported

Bottom line: Treat scrollbar-color as progressive enhancement. Unsupported browsers keep default scrollbars and scrolling still works normally.

Conclusion

The scrollbar-color property provides a simple way to customize the appearance of scrollbars, allowing you to create a more cohesive and visually appealing design.

By experimenting with different thumb and track colors, you can ensure that every aspect of your website matches your design vision. Keep browser compatibility in mind so your custom scrollbars are effective across the platforms your users rely on.

💡 Best Practices

✅ Do

  • Apply scrollbar-color on elements that actually scroll with overflow: auto or scroll
  • Use enough contrast between thumb and track colors
  • Match scrollbar colors to your light or dark theme
  • Pair with scrollbar-width: thin for compact panels
  • Test in Firefox and Chrome where support is strongest

❌ Don’t

  • Expect custom colors on every mobile browser — iOS often uses overlay scrollbars
  • Use colors so similar that the thumb disappears into the track
  • Forget that the first color is the thumb and the second is the track
  • Replace working scrollbars with non-scrollable overflow just for styling

Key Takeaways

Knowledge Unlocked

Five things to remember about scrollbar-color

Use these points when styling scrollable panels and sidebars.

5
Core concepts
02

Thumb + Track

Two color values.

Syntax
03

Scrollable box

Needs overflow.

Target
04

Firefox & Chrome

Best support.

Browsers
🔄 05

scrollbar-width

Pair for size.

Companion

❓ Frequently Asked Questions

scrollbar-color sets the colors of a scrollbar thumb and track on scrollable elements. The first color is the thumb and the second color is the track.
The thumb is the draggable part of the scrollbar. The track is the background groove behind the thumb.
The default value is auto, which lets the browser and operating system choose the scrollbar colors.
Apply it to elements that scroll, such as divs, sections, or sidebars with overflow set to auto or scroll.
Use it when you want scrollbars to match your site theme without writing full WebKit scrollbar pseudo-element styles. Pair it with scrollbar-width when you also want to change scrollbar size.

Practice in the Live Editor

Open the HTML editor and try scrollbar-color: blue lightgray; on a scrollable div with overflow: auto.

HTML Editor →

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.

5 people found this page helpful