Description
We recently resolved to add general-purpose :open
and :closed
pseudo classes, which apply to "things that can open and close". While not defined in CSSWG, the stated intention was to include things like <details>
, <select>
, <dialog>
, and Popover.
@jakearchibald recently raised the issue that in some cases, this is ambiguous, because there are multiple "ways" that something can be open or closed, and both might apply at the same time. Take, as an example, <details popover>
, which can be "open" as a popover, but "closed" as a details, or vice versa. There's no way for these to be disambiguated on the basis of :open
or :closed
alone.
It is a bit unclear whether fullscreen elements should be included as "something that can open and close", but it's possible. That allows the possibility of a fullscreen <details>
element which can be both open and closed. But fullscreen elements have a dedicated pseudo, :fullscreen
, which allows one to disambiguate that state of openness vs. others.
It would seem that we need another such pseudo for popovers, because any element can also be a popover, and can therefore run into this dual-states problem. We discussed this in OpenUI, and proposed :popover
as a pseudo class that applies only to popovers that are open (as a popover). That would allow developers to do:
details[popover]:closed:popover {
/* styles for a non-expanded details that is open as a popover */
}