Customize the Dropdown Scrollbar with CSS

Flavio Corpa
InstructorFlavio Corpa
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 weeks ago

This is the only lesson in which we will fallback to CSS to give our dropdown's scrollbar a fancier look because this is very browser dependent and there is no way (yet) to do this with elm-ui.

We will target ::-webkit-scrollbar, ::-webkit-scrollbar-track, and ::-webkit-scrollerbar-thumb to get the scrollbar looking exactly how we want it.

Lecturer: [0:00] Now that our dropdown is looking awesome, there is one small change that we want to do, and it's to customize the dropdown's list of options scrollbar. For doing that, unfortunately we need to fall back to CSS.

[0:14] Let's now open our main CSS, and we need to add the following code, webkit-scrollbar. We're going to give it a weight of 20px. Now we say webkit-scrollbar-track, and we say that the background is going to be transparent.

[0:30] Now we want to highlight webkit-scrollbar-thumb. We're going to say the background color is going to be 9b9b9b. The border is going to be 7px solid transparent. The border width is going to be and 7px, the border-radius is going to be 8px, and finally, the background-clip is going to be content-box.

[0:59] Now, if we have a look at our scrollbar, it's looking much better, and this is the only piece of CSS that we're going to write in this whole Elm UI course.