could you use the :checked or :has selector for opening up mobile menus? i currently use JS for that and feel a bit guilty about it, yet i dont really know how to do it in pure CSS and hide the checkbox somehow
I was able to make some complex hover menus and sidebar toggles work like this entirely without JavaScript. It's also accessible, to the user. The downside is that for the developer, the resulting code is not easy to read nor maintain.
I would link to it but it's in a private repository atm. One day I'll open source this behavior as its own package... one day...
Stick to using a button with an aria-expanded state to toggle. You can make the sibling menu contents visible based on that state.
button.menu[aria-expanded="false"] + .menu-list { display: none; } button.menu[aria-expanded="true"] + .menu-list { display: block; }
the relevant style applied looks like this:
.modal-open, .modal:target, .modal-toggle:checked+.modal {
pointer-events: auto;
visibility: visible;
opacity: 1;
}