{"id":297747,"date":"2019-10-28T15:13:16","date_gmt":"2019-10-28T22:13:16","guid":{"rendered":"https:\/\/css-tricks.com\/?p=297747"},"modified":"2019-10-28T15:13:16","modified_gmt":"2019-10-28T22:13:16","slug":"the-current-state-of-styling-selects-in-2019","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/the-current-state-of-styling-selects-in-2019\/","title":{"rendered":"The Current State of Styling Selects in 2019"},"content":{"rendered":"
Best I could tell from the last time I compiled the most wished-for features of CSS<\/a>, styling form controls was a major ask. Top 5, I’d say. And of the native form elements that people want to style, Greg Whitworth has some data<\/a> that the Developers clearly want to style select dropdowns.<\/p>\n <\/p>\n The best crack at this out there comes from Scott Jehl over on the Filament Group blog<\/a>. I’ll embed a copy here so it’s easy to see:<\/p>\n \n See the Pen Notably, this is an entirely cross-browser solution. It’s not something limited to only the most progressive desktop browsers. There are some visual differences across browsers and platforms, but overall it’s pretty consistent and gives you a baseline from which to further customize it.<\/p>\n Open the select. Hmm, it looks and behaves like you did nothing to it at all.<\/p>\n Some browsers do let you style the inside, but it’s very limited. Any time I’ve gone down this road, I’ve had a bad time getting things cross-browser compliant.<\/p>\n Boiled down, the most painful parts of styling selects are:<\/p>\n I’m surprised multi-select didn’t make the cut. Maybe it’s not on the table for Edge recently announced they are improving the look<\/a> of form controls, but no word just yet on standards or how to customize them.<\/p>\n<select><\/code> element is more requested than any other element — more than double the next element — and<\/em> it’s the one developers most often customize in some way. <\/p>\n
You actually do a little. Perhaps more than you realize.<\/h3>\n
\n select-css by Scott\/Filament Group<\/a> by Chris Coyier (@chriscoyier<\/a>)
\n on CodePen<\/a>.<\/span>\n<\/p>\nThat’s just the “outside”<\/h3>\n
<select><\/code> doesn’t do anything to the opened dropdown of items. (Screenshot from macOS Chrome)<\/figcaption><\/figure>\n
\n\n
\n \nFrustration<\/th>\n %<\/th>\n Count<\/th>\n<\/tr>\n<\/thead>\n \n Not being able to create a good user experience for searching within the list<\/td>\n 27.43%<\/td>\n 186<\/td>\n<\/tr>\n \n Not being able to style the <option> element to the extent that you needed to<\/td>\n 17.85%<\/td>\n 121<\/td>\n<\/tr>\n \n Not being able to style the default state (dropdown arrow, etc.)<\/td>\n 14.01%<\/td>\n 95<\/td>\n<\/tr>\n \n Not being able to style the pop-up window on desktop (e.g. the border, drop shadows, etc.)<\/td>\n 11.36%<\/td>\n 77<\/td>\n<\/tr>\n \n Insertion of content beyond simple text in the <select> control or its <option>s<\/td>\n 11.21%<\/td>\n 76<\/td>\n<\/tr>\n \n Insertion of arbitrary HTML content in an <option> element<\/td>\n 7.82%<\/td>\n 53<\/td>\n<\/tr>\n \n Not being able to create distinctive unselected\/placeholder style and behavior<\/td>\n 3.39%<\/td>\n 23<\/td>\n<\/tr>\n \n Being able to generate new options from a large dataset while the popup is open<\/td>\n 3.10%<\/td>\n 21<\/td>\n<\/tr>\n \n Not being able to style the currently selected <option>(s) to the extent you needed to<\/td>\n 1.77%<\/td>\n 12<\/td>\n<\/tr>\n \n Not being able to style the pop-up window on mobile<\/td>\n 1.03%<\/td>\n 7<\/td>\n<\/tr>\n \n Being able to have the options automatically repeat on scroll (i.e., if you have an list of options 1 \u2013 100, as you reach 100 rather than having the user scroll back to the top, have 1 show up below 100)<\/td>\n 1.03%<\/td>\n 7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \n
<select><\/code> since it wouldn’t be backwards-compatible?<\/p>\n
Browser evolution<\/h3>\n