Menu

CSS-only Offcanvas with Native HTML
📰

CSS-only Offcanvas with Native HTML

DEV Community: html·David Day·about 8 hours ago
#okqGBj5x
#devto2#devto#dev#offcanvas#dialog
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.