Ctrl + K
CSS10 min read

CSS Scrollbars Guide

Discover how CSS scrollbar styling works, explore browser-specific properties and learn best practices for creating modern scrollbars.

Published: 2026-08-01

Scrollbars are an essential part of user interaction, allowing visitors to navigate content that extends beyond the visible area. Modern CSS provides several ways to customize their appearance while maintaining usability and accessibility.

Although browser support differs slightly across platforms, well-designed custom scrollbars can improve the visual consistency of websites without affecting scrolling behavior.

Why Customize Scrollbars?

Default scrollbars vary between operating systems and browsers. Custom styling helps align them with your site's branding while preserving familiar interaction patterns.

Scrollbar Components

ComponentPurpose
TrackBackground area
ThumbDraggable handle
CornerIntersection of two scrollbars

Firefox Scrollbar Properties

Firefox supports standardized scrollbar customization through the scrollbar-width and scrollbar-color properties.

body {
  scrollbar-width: thin;
  scrollbar-color: #666 #eee;
}

scrollbar-width

ValueDescription
autoDefault width
thinNarrow scrollbar
noneHide scrollbar

scrollbar-color

This property defines separate colors for the draggable thumb and the scrollbar track.

WebKit Scrollbars

Chromium-based browsers and Safari support scrollbar customization using the ::-webkit-scrollbar family of pseudo-elements.

::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-thumb {
  background: #666;
}

::-webkit-scrollbar-track {
  background: #eee;
}

Common WebKit Pseudo-elements

Pseudo-elementPurpose
::-webkit-scrollbarEntire scrollbar
::-webkit-scrollbar-thumbDraggable thumb
::-webkit-scrollbar-trackScrollbar track
::-webkit-scrollbar-cornerScrollbar corner

Horizontal Scrollbars

The same styling techniques apply to horizontal scrollbars, making it possible to create visually consistent galleries, tables and code blocks.

Typical Use Cases

  • Code editors.
  • Documentation pages.
  • Image galleries.
  • Data tables.
  • Custom dashboards.
💡 Keep scrollbar styling subtle so users immediately recognize it as a familiar interface element.
⚠️ Completely hiding scrollbars may reduce discoverability and negatively affect accessibility for some users.

Choosing Colors

Scrollbar colors should complement the overall interface while maintaining sufficient contrast between the thumb and track. A thumb that blends into the track may be difficult for users to locate.

Scrollbar Size

Very thin scrollbars create a clean appearance but may become difficult to grab, especially on desktop devices. Balancing aesthetics with usability is important.

Hover Effects

Changing the thumb color when users hover over it provides useful visual feedback and improves discoverability.

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

Rounded Scrollbars

Rounded corners create a softer appearance that fits modern interface styles. Border radius is commonly applied to scrollbar thumbs in WebKit-based browsers.

::-webkit-scrollbar-thumb {
  border-radius: 999px;
}

Browser Support

Scrollbar customization is not fully standardized across browsers. Firefox uses standardized properties, while Chromium-based browsers and Safari rely on WebKit pseudo-elements.

BrowserSupported Method
Firefoxscrollbar-width, scrollbar-color
Chrome::-webkit-scrollbar
Edge::-webkit-scrollbar
Safari::-webkit-scrollbar

Accessibility

Custom scrollbars should remain clearly visible, large enough to interact with and distinguishable from surrounding interface elements. Avoid reducing their size or contrast excessively.

Performance

Scrollbar styling has minimal performance impact because only a few interface elements are affected. Complex shadows and animations generally remain inexpensive compared with other visual effects.

Common Mistakes

  • Making scrollbars too thin.
  • Using insufficient color contrast.
  • Hiding scrollbars completely.
  • Ignoring browser-specific syntax.
  • Overusing decorative effects.

Best Practices

Keep scrollbar styling consistent with your site's design, preserve usability across devices, provide adequate contrast and always test customization in multiple browsers because implementation details differ.

💡 Generate your scrollbar styles visually first, then fine-tune colors and sizing manually for the best cross-browser experience.
⚠️ Avoid removing visible scrollbars entirely unless an alternative scrolling indicator is provided, as hidden scrollbars may reduce usability and accessibility.

Frequently Asked Questions

Can CSS fully customize scrollbars?

Yes, but support depends on the browser. Firefox uses the standardized scrollbar-width and scrollbar-color properties, while Chrome, Edge and Safari rely on the ::-webkit-scrollbar pseudo-elements for more detailed customization.

Can I change scrollbar colors?

Yes. Both Firefox and WebKit-based browsers allow you to customize the colors of the scrollbar thumb and track, although the syntax differs between browsers.

Is it a good idea to hide scrollbars?

Generally no. Completely hiding scrollbars can make scrolling less discoverable and may reduce accessibility. If you hide them, ensure users still have a clear indication that content can be scrolled.

Do custom scrollbars affect performance?

Scrollbar styling usually has very little performance impact. Simple color changes and rounded corners are inexpensive, while heavy shadows or animations may add a small rendering cost.

Should scrollbar styles match the website theme?

Yes. Scrollbars should complement the overall design while remaining clearly visible and easy to interact with. Good contrast and reasonable sizing are more important than decorative effects.

Helpful CSS Tools

A CSS Scrollbar Generator helps create cross-browser scrollbar styles visually, a CSS Formatter keeps generated CSS clean and consistent, a Color Converter simplifies switching between HEX, RGB and HSL color formats, a CSS Accent Color Generator assists with choosing interface colors that complement custom scrollbars, and a CSS Border Generator helps create rounded scrollbar thumbs that match modern UI styles.

Conclusion

Custom CSS scrollbars allow websites to achieve a more polished and consistent appearance while preserving familiar scrolling behavior. By combining standardized Firefox properties with WebKit pseudo-elements, developers can style scrollbars across modern browsers with minimal effort. Keeping scrollbars visible, maintaining strong contrast and testing across platforms ensures that customization enhances both aesthetics and usability without sacrificing accessibility.