Tillitsdone
down Scroll to discover

CSS scrollbar-color Customizing Scrollbars for Better Design

Explore the CSS scrollbar-color property to customize scrollbar colors for better design and user experience.

Learn about available options and usage.
thumbnail

Introduction

The scrollbar-color property in CSS lets you customize the appearance of scrollbars. By setting the color of the scrollbar thumb (the part you drag) and track (the background), you can improve the visual appeal and user experience of your web pages. This article covers the scrollbar-color property, its syntax, values, accessibility considerations, and practical examples to help you use this feature effectively in your web projects.

Understanding the scrollbar-color Property

The scrollbar-color property allows you to customize the colors of the scrollbar thumb and track. This property can significantly enhance the visual appeal of your web designs when applied to elements with overflow.

Components of the Scrollbar

  • Thumb: The part of the scrollbar that users drag to scroll through content.
  • Track: The background area of the scrollbar.

By customizing these components, you can make your scrollbars more visually appealing and consistent with your design aesthetic.

Syntax

The syntax for the scrollbar-color property is straightforward:

/* Keyword values */
scrollbar-color: auto;
/* <color> values */
scrollbar-color: rebeccapurple green; /* Thumb color is rebeccapurple, track color is green */
/* Global values */
scrollbar-color: inherit;
scrollbar-color: initial;
scrollbar-color: revert;
scrollbar-color: revert-layer;
scrollbar-color: unset;

Explanation of Syntax

  • auto: Lets the browser use its default rendering for the scrollbar.
  • <color> <color>: Sets custom colors for the thumb and track.
  • Global values:
    • inherit: Inherits the color properties from the parent element.
    • initial: Resets the scrollbar color to its initial default value.
    • revert: Reverts the scrollbar color to the browser’s default style.
    • revert-layer: Similar to revert, but respects CSS cascade layers.
    • unset: Acts as a shorthand for initial or inherit.

Property Values

The scrollbar-color property accepts several values that let you customize the appearance of the scrollbar.

Keyword Values

  • auto: Uses the browser’s default rendering.

Color Values

  • <color> <color>: Specifies custom colors for the thumb and track.

Global Values

  • inherit: Inherits colors from the parent element.
  • initial: Resets to the initial default value.
  • revert: Reverts to the browser’s default style.
  • revert-layer: Reverts while considering CSS cascade layers.
  • unset: Shorthand for initial or inherit.

Examples of Property Values

/* Using the auto keyword */
.scrollbar-auto {
scrollbar-color: auto;
}
/* Using custom colors */
.scrollbar-colored {
scrollbar-color: red green; /* Thumb color is red, track color is green */
}
/* Using global values */
.scrollbar-inherit {
scrollbar-color: inherit;
}
.scrollbar-initial {
scrollbar-color: initial;
}
.scrollbar-revert {
scrollbar-color: revert;
}
.scrollbar-revert-layer {
scrollbar-color: revert-layer;
}
.scrollbar-unset {
scrollbar-color: unset;
}

Important Notes

  • Accessibility: Ensure enough contrast between thumb and track colors for accessibility.
  • Browser Compatibility: Check browser compatibility before using this property.

Accessibility

When using the scrollbar-color property, consider accessibility to ensure all users can easily interact with your webpage.

Contrast Ratio

  1. Ensure Sufficient Contrast: Use a contrast ratio of at least 3:1 between the thumb and track colors.
  2. User Agent Responsibilities: For auto, user agents should ensure default colors have enough contrast.

Practical Tips

  • Test Different Color Combinations: Use tools like color contrast checkers to verify accessibility.
  • Dark Mode Considerations: Adjust scrollbar colors for dark mode.
  • High Contrast Mode: Consider how colors will appear in high contrast mode.

Example

.accessible-scrollbar {
scrollbar-color: #007 #bada55; /* Custom scrollbar colors with sufficient contrast */
}

Additional Resources

  • WCAG Guidelines: Refer to [WCAG 2.0 Techniques for G183]WebsiteUrl for detailed information.
  • Color Contrast Checkers: Use online tools like the [WebAIM Color Contrast Checker]WebsiteUrl.

Browser Compatibility

The scrollbar-color property has varying support across browsers. Understanding this can help you make informed decisions about its use.

Current Support

  • Google Chrome: Supported in recent versions.
  • Mozilla Firefox: Supported.
  • Microsoft Edge: Supported.
  • Opera: Supported.
  • Safari: Limited support.

Browser Compatibility Table

BrowserSupport Status
Google ChromeSupported
Mozilla FirefoxSupported
Microsoft EdgeSupported
OperaSupported
SafariLimited Support

Fallbacks and Alternatives

  • Progressive Enhancement: Use scrollbar-color as a progressive enhancement.
  • Feature Detection: Use JavaScript to detect support.
  • CSS Custom Properties: Use variables to manage styles.

Example with Fallback

/* Define custom properties for scrollbar colors */
:root {
--scrollbar-thumb-color: #007;
--scrollbar-track-color: #bada55;
}
/* Apply scrollbar-color property */
.scroller {
width: 300px;
height: 100px;
overflow-y: scroll;
scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);
}
/* Fallback for browsers that do not support scrollbar-color */
.scroller::-webkit-scrollbar-thumb {
background-color: var(--scrollbar-thumb-color);
}
.scroller::-webkit-scrollbar-track {
background-color: var(--scrollbar-track-color);
}

Examples

Example 1: Using scrollbar-color with auto

.scrollbar-auto {
scrollbar-color: auto;
}

Example 2: Using Custom Colors

.scrollbar-colored {
scrollbar-color: rebeccapurple green; /* Thumb color is rebeccapurple, track color is green */
}

Example 3: Using Global Values

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

Example 4: Ensuring Accessibility

.accessible-scrollbar {
scrollbar-color: #007 #bada55; /* Custom scrollbar colors with sufficient contrast */
}

Example 5: Example with Fallback

/* Define custom properties for scrollbar colors */
:root {
--scrollbar-thumb-color: #007;
--scrollbar-track-color: #bada55;
}
/* Apply scrollbar-color property */
.scroller {
width: 300px;
height: 100px;
overflow-y: scroll;
scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);
}
/* Fallback for browsers that do not support scrollbar-color */
.scroller::-webkit-scrollbar-thumb {
background-color: var(--scrollbar-thumb-color);
}
.scroller::-webkit-scrollbar-track {
background-color: var(--scrollbar-track-color);
}

By understanding and using the scrollbar-color property effectively, you can enhance the visual appeal and user experience of your web projects. Always consider accessibility and browser compatibility to ensure a consistent and inclusive experience for all users.

icons/logo-tid.svg Latest Blogs
Discover our top articles, selected to support the growth of your business.
https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F10%2FTill-its-done_SEO_R39_Sep_1440x697.jpg@webp Web Development Frameworks: React vs Vue vs Angular vs Svelte ตัวไหนน่าใช้ เปรียบเทียบ React vs Vue vs Angular vs Svelte แบบเข้าใจง่าย เจาะคุณสมบัติ และสรุปให้ว่าเหมาะกับใคร เพื่อให้ช่วยเลือก Framework ที่ใช่ในปี 2025 https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F10%2FTill-its-done_SEO_R38_Sep_1440x697.jpg@webp TypeScript Interface คืออะไร? อธิบายพร้อมวิธีใช้และข้อแตกต่างจาก Type เรียนรู้วิธีใช้ TypeScript Interface เพื่อสร้างโครงสร้างข้อมูลที่ปลอดภัยและเข้าใจง่าย พร้อมเปรียบเทียบข้อดีข้อแตกต่างกับ Type ที่คุณต้องรู้ ถูกรวมเอาไว้ในบทความนี้แล้ว https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F09%2FTill-its-done_SEO_R36_Sep_1440x697.jpg@webp Material-UI (MUI) คืออะไร อยากสร้าง UI สวยงามและเป็นมืออาชีพในเวลาอันรวดเร็วใช่ไหม มาทำความรู้จักกับ Material-UI (MUI) ที่ช่วยให้คุณพัฒนาแอปพลิเคชันบน React ได้ง่ายและดูดีในทุกอุปกรณ์ https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F09%2FTill-its-done_SEO_R35_Sep_1440x697.jpg@webp มือใหม่อยากเริ่มเขียนแอป ต้องใช้โปรแกรมและภาษาอะไรบ้าง? อยากเป็นนักพัฒนาแอปแต่ไม่รู้จะเริ่มยังไง พบกับแนวทางการเลือกเครื่องมือและภาษาเบื้องต้นพร้อมคำแนะ เพื่อก้าวสู่เส้นทางการเขียนแอปอย่างมั่นใจในบทความนี้ https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F09%2FTill-its-done_SEO_R27_Sep_1440x697.jpg@webp เปรียบเทียบ 3 วิธีติดตั้ง install node js บน Ubuntu: NVM vs NodeSource vs Official Repo แบบไหนดีที่สุด? เรียนรู้วิธีติดตั้ง Node.js บน Ubuntu ด้วย NVM, NodeSource หรือ Official Repo เลือกวิธีที่เหมาะกับความต้องการของคุณ พร้อมเปรียบเทียบ เพื่อการพัฒนาที่มีประสิทธิภาพ! https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F09%2FTill-its-done_SEO_R26_Sep_1440x697.jpg@webp Next js image การ Optimization รูปภาพแบบ Native ที่มีประสิทธิภาพสูง เรียนรู้วิธีใช้ Next.js Image เพื่อ Optimization การแสดงภาพบนเว็บไซต์ ด้วยเทคนิคบีบอัด ปรับขนาด Lazy Load และรองรับ Responsive ช่วยให้เว็บคุณโหลดเร็วขึ้นแน่นอน!
icons/logo-tid.svg

Talk with CEO

Ready to bring your web/app to life or boost your team with expert Thai developers?
Contact us today to discuss your needs, and let’s create tailored solutions to achieve your goals. We’re here to help at every step!
🖐️ Contact us
down Explore our best articles, cover a wide variety of technologies
Our knowledge base
196 Articles
Explore right
icons/logo-react.svg ReactJs
Popular JavaScript library for building user interfaces with a component-based architecture.
160 Articles
Explore right
icons/flutter.svg Flutter
UI toolkit for building natively compiled applications for mobile, web, and desktop from a single codebase.
144 Articles
Explore right
icons/logo-nodejs.svg Nodejs
JavaScript runtime for building scalable, high-performance server-side applications.
58 Articles
Explore right
icons/next-js.svg Nextjs
React framework enabling server-side rendering and static site generation for optimized performance.
38 Articles
Explore right
icons/tailwind.svg TailwindCSS
Utility-first CSS framework for rapid UI development.
36 Articles
Explore right
icons/code-outline.svg Typescript
Superset of JavaScript adding static types for improved code quality and maintainability.
126 Articles
Explore right
icons/code-outline.svg Golang
Programming language known for its simplicity, concurrency model, and performance.
67 Articles
Explore right
icons/code-outline.svg AstroJs
Astro is an all-in-one web framework. It includes everything you need to create a website, built-in.
38 Articles
Explore right
icons/code-outline.svg Jest
Versatile testing framework for JavaScript applications supporting various test types.
14 Articles
Explore right
icons/code-outline.svg Website development th
10 Articles
Explore right
icons/code-outline.svg Mobile application th
5 Articles
Explore right
icons/code-outline.svg Reactjs th
3 Articles
Explore right
icons/code-outline.svg Flutter th
3 Articles
Explore right
icons/code-outline.svg Nextjs th
1 Articles
Explore right
icons/code-outline.svg Software house th
1 Articles
Explore right
icons/code-outline.svg Nodejs th
1 Articles
Explore right
icons/code-outline.svg Typescript th
337 Articles
Explore right
icons/css-4.svg CSS
CSS3 is the latest version of Cascading Style Sheets, offering advanced styling features like animations, transitions, shadows, gradients, and responsive design.
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
FacebookInstagramLinkedIn
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.