I almost missed this great post by Una Kravets on the upcoming changes to the <select>
element where soon we’ll be able to customize it to our heart’s content without the need to hack things together. Una shows how we’ll be able to do that soon with just this little bit of CSS:
select,
::picker(select) {
appearance: base-select;
}
A few visual changes are made by default which is weird and interesting, but the most important thing is that now under the hood we have access to style the popover when we click that <select>
. This is rad as hell and I can’t wait for this to land in browsers.
This is a neat detail, too:
The new customizable <select>
uses functionality from popover and anchor positioning. It's built with these two underlying technologies. This means that the drop-down option list within a select acts as a popover which is anchored to the trigger button that opens the select.
Update: inset-area
has been renamed to position-area
since this post was published! You can read more about these syntax changes here.
I’ve been half-ignoring anchor positioning but patiently waiting for it to land in browsers for a while now. But this explanation by Brecht yesterday reminded me to buckle up and learn it all properly since it just landed in the latest version of Chrome and Edge.
One thing I hadn’t heard of before Brecht’s post was the inset-area
property which sure is handy. As he explains, it lets you draw a grid around an element and then position something left/right/up/down within it:
.anchored {
position: absolute;
position-anchor: --anchortome;
position-area: top span-all;
}
This feels like how I’d anchor-position something like a tooltip maybe 95% of the time which is neat. But! Although anchor positioning sure is going to be amazing for tooltips, it goes far beyond that. Re-reading Roman Komarov’s post from last year made me spit-take again:
It becomes possible to highlight something in a completely different place on the page, allowing elements to “know of each other”.
Not only does that sound punk rock and strangely ominious, I think that’s what anchor positioning really opens up.