DEV Community

Cover image for Future of CSS: Select styling without the hacks

Future of CSS: Select styling without the hacks

Andrew Bone on March 10, 2025

For years the <select> element has been notoriously difficult to style. Developers had to either accept the browser’s default look or resort ...
Collapse
 
moopet profile image
Ben Sinclair

I have some concerns about this - a lot of devices have their own native way of presenting choices (like the rolodex thing on iOS for example). In the same way as with the JS solutions, we don't want to be replacing the familiar, optimised native behaviour - at least not in all circumstances. And if we do it only in some cases, then the app becomes inconsistent.

I'm not sure what the solution is, though.

Collapse
 
link2twenty profile image
Andrew Bone

Fortunately you only see the replaced listmenu on desktop leaving mobile with its native feel, that's how it works on android at least we'll have to wait and see if its the same on iOS.

Collapse
 
laikokwui profile image
Lai Kok Wui

i didnt know we can add codepen in the post cool

Collapse
 
learncomputer profile image
Learn Computer Academy

Nice overview of base-select! It’s great to see CSS addressing the styling issue without needing JavaScript. The native styling options for the picker and options look promising, and the shadcn/ui demo is a solid example. Limited browser support is a challenge for now, but I’m looking forward to using this once it’s more widely available. Good post!

Collapse
 
nadeem_zia_257af7e986ffc6 profile image
nadeem zia

Good information provided, thanks

Collapse
 
link2twenty profile image
Andrew Bone

You're welcome 😊

Collapse
 
kurealnum profile image
Oscar

How are you highlighting your code here?

Image description

Collapse
 
link2twenty profile image
Andrew Bone

code block with no colors example

... to specify the language:

code block with colors example

More details in the editor guide.

Collapse
 
kurealnum profile image
Oscar

I meant the "glow" on the &::picker(select). Sorry for the confusion!

Thread Thread
 
link2twenty profile image
Andrew Bone

Oh, that's because the linter Forem are using doesn't know what it is. The glow is the error state.

Thread Thread
 
kurealnum profile image
Oscar

Oh, interesting. Thanks!

Collapse
 
puntloos13 profile image
codagonist

To bad these sort of 'fixes' aren't cross-browser or -device and if I'm not mistaken semantically incorrect. Interesting post nonetheless..

Collapse
 
link2twenty profile image
Andrew Bone

This will be cross browser. It's new to the spec it just so happens that chrome were the first to implement it. 😊

Collapse
 
code-with-aeon profile image
Gabriel Ibañez

Thanks for the resource