CSS Scrollbar Generator
Custom scrollbars used to be a nightmare of vendor-prefixed pseudo-elements. Today, scrollbar-color and scrollbar-width handle the common cases in all modern browsers, narrow or normal width, and two-colour (thumb + track) theming. For pixel-level control (track padding, thumb radius, hover states) the older ::-webkit-scrollbar pseudo-elements still work in Chrome and Safari. This generator outputs both, cascading correctly.
How to style a scrollbar
-
1
Pick the width
Auto (default platform width), thin (narrower), or a specific pixel value via the webkit rules.
-
2
Set thumb and track colours
Modern `scrollbar-color` takes two colours. Webkit rules give separate colour, radius and hover states.
-
3
Add hover effect (optional)
Thumb brightens on hover. Works via `::-webkit-scrollbar-thumb:hover`.
-
4
Decide scope
Apply to `html` / `body` (whole page), or to a specific scrolling container only.
-
5
Copy CSS
Combined modern + webkit rules: works in every modern browser with graceful fallback.
Modern standard properties (2023+)
/* Applies to the element that scrolls */
html {
scrollbar-width: thin; /* auto | thin | none */
scrollbar-color: #4f46e5 #e5e7eb; /* thumb track */
}
Browser support (2024):
scrollbar-width: Chrome 121+, Safari 18.2+, Firefox 64+.scrollbar-color: Chrome 121+, Safari 18.2+, Firefox 64+.scrollbar-gutter: stable: Chrome 94+, Safari 14+, Firefox 97+. Reserves the scrollbar space even when not needed, preventing layout shift.
Webkit pseudo-elements (Chrome, Safari, older Edge)
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
background: #e5e7eb;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: #4f46e5;
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: #3730a3;
}
More granular control. width sets vertical scrollbar width; height sets horizontal scrollbar height. Add both for containers that can scroll in either direction.
Cascade the two approaches
Specify the modern rules first, then webkit as an enhancement for browsers that render both:
.scroll-area {
scrollbar-width: thin;
scrollbar-color: #4f46e5 #e5e7eb;
}
.scroll-area::-webkit-scrollbar { width: 8px; }
.scroll-area::-webkit-scrollbar-track { background: #e5e7eb; }
.scroll-area::-webkit-scrollbar-thumb {
background: #4f46e5;
border-radius: 4px;
border: 2px solid #e5e7eb;
}
Firefox honours only the modern scrollbar-* rules. Chrome and Safari honour the webkit rules (which override the modern ones, so behaviour is consistent).
scrollbar-gutter prevents content shift
Without a reserved gutter, content reflows when a scrollbar appears (common on dynamic lists). Fix:
html { scrollbar-gutter: stable; }
/* or */
html { scrollbar-gutter: stable both-edges; }
The scrollbar slot is reserved whether or not the content scrolls. both-edges adds a matching gutter on the opposite side to keep content visually centred.
Hide scrollbars entirely
.no-scrollbar {
scrollbar-width: none; /* Firefox */
}
.no-scrollbar::-webkit-scrollbar { display: none; } /* Chrome, Safari */
Be careful: hiding the scrollbar prevents users from seeing that content can scroll. Use only with a clear indicator (arrows, page dots) or when the scroll behaviour is obvious from context (horizontal carousels, chat histories).
Mobile considerations
On iOS and Android, scrollbars only appear momentarily during scroll. Your custom scrollbar CSS still applies, but users may never see it for more than a second. Design accordingly, do not invest heavily in visual flair that rarely appears.
Accessibility
- Contrast: thumb against track should meet 3:1 for non-text contrast (WCAG 1.4.11).
- Width: thin scrollbars can be hard to grab with a mouse, especially for users with motor impairments. Normal width is a safer default.
- Never remove the scrollbar on scrolling regions without providing another scroll affordance. Users who rely on the scrollbar will be stuck.
Frequently Asked Questions
Yes, with the modern scrollbar-width and scrollbar-color properties. Firefox does not support the webkit pseudo-elements, so for consistent appearance across browsers use the modern properties first and add webkit rules as an enhancement.
Because default scrollbars overlay content and reserve no space until needed. Set scrollbar-gutter: stable on the scrolling element to always reserve the gutter, preventing reflow when the scrollbar appears or disappears.
Usually yes, because the scrollbar looks out of place and competes with the content. Add visible pagination dots or arrow controls so users still know the content scrolls. Respect prefers-reduced-motion if scroll-snapping.
It can. Very thin or low-contrast scrollbars are hard to use for motor-impaired and low-vision users. Keep the scrollbar at least 8-10 px wide for comfortable grabbing, and maintain 3:1 contrast between thumb and track.
Related Tools
ASCII Table Reference
Full ASCII table from 0 to 127 with decimal, hex, octal, binary, standard names and HTML numeric-reference notation, including NUL, LF and DEL.
HEX Color Picker
Pick or enter a HEX colour and get RGB, HSL, approximate CMYK, relative luminance and contrast ratios against white and black.
Color Palette Generator
Generate monochromatic, analogous, complementary, triadic or tetradic color palettes from a base HEX color and export copy-ready CSS variables.
HTML Character Reference
Searchable list of HTML entities, their named and numeric codes, and a one-click copy for special characters and symbols.
FPS Counter
Measure browser FPS with requestAnimationFrame, smoothing, min/max frame rate, warnings and an optional graph. Runs locally with no upload or API.
JSON Formatter
Paste JSON to pretty-print with 2 or 4 spaces, minify it to compact output, or run a quick syntax check before copying the result.