I previously wrote an article on my rewrite of PicoCSS . One of the components that I introduced in the rewrite was a CSS-only and classless offcanvas using native HTML.
On the HTML side, the component works by leveraging the native <dialog> element along with command / commandfor attributes. According to the Mozilla Developer Network, the <dialog> element has been available across browsers since March 2022 and the command / commandfor attributes since December 2025
On the CSS side, the component leverages :has pseudo-class to assert a specific markup and when the user doesn't have a preference specified for the prefers-reduced-motion setting then it uses the transform property.…