CSS Custom Scrollbar Styling
Style scrollbars using CSS scrollbar-width and webkit pseudo-elements for consistent cross-browser visual design.
Code
.scroll-area {
scrollbar-width: thin;
scrollbar-color: #4f46e5 transparent;
}
.scroll-area::-webkit-scrollbar {
width: 8px;
}
.scroll-area::-webkit-scrollbar-thumb {
background: #4f46e5;
border-radius: 4px;
}CSS Custom Scrollbar Styling
Style scrollbars using CSS scrollbar-width and webkit pseudo-elements for consistent cross-browser visual design.
Code
.scroll-area {
scrollbar-width: thin;
scrollbar-color: #4f46e5 transparent;
}
.scroll-area::-webkit-scrollbar {
width: 8px;
}
.scroll-area::-webkit-scrollbar-thumb {
background: #4f46e5;
border-radius: 4px;
}
Explanation
scrollbar-width and the ::-webkit-scrollbar pseudo-elements restyle the scrollbar to match the palette. Expected behavior: Firefox honours scrollbar-width and scrollbar-color, while Chromium and Safari honour the WebKit pseudo-elements. Limitation: no single syntax covers every engine, so both rule sets must be shipped together.
Interactive Tools for This Topic
CSS to Tailwind ConverterConvert standard CSS layout, spacing, typography, border, and color declarations into Tailwind utility classes along with unmapped property notes.Aspect Ratio CalculatorSimplify a width-to-height ratio, show its decimal value, and derive a matching height for a new width.Border Radius PreviewPreview four-corner border-radius values on a live box and copy the generated shorthand border-radius CSS declaration.Box Shadow GeneratorBuild CSS box-shadow values with offset, blur, spread, color, opacity, and inset controls, with a live preview of the result.
Report a problem with this exampleOpens a pre-filled issue on GitHub.