An off-canvas side drawer built with pure CSS and the checkbox hack, without a single line of JavaScript. A Menu button in the top bar slides in a navigation panel with icons, count badges, a team list and a user card, while a dimmed scrim covers the page. Use it as the mobile navigation of an app, a dashboard sidebar or a filter panel on sites where you want to avoid scripts.
How it works
The root .od-shell is positioned relatively and clips its children. Its first child is the input.od-toggle checkbox, which stores the open state. Three label elements point to it with for="od-toggle-1": .od-burger in the .od-bar header, .od-close inside the drawer and the full-size .od-scrim. Clicking any of them toggles the checkbox.
All the behavior comes from the general sibling selector. .od-toggle:checked ~ .od-drawer slides the nav.od-drawer from translateX(-100%) to 0, .od-toggle:checked ~ .od-scrim fades in the overlay, and .od-toggle:checked ~ .od-bar .od-burger-lines morphs the three burger lines into an X. While the drawer is closed it also has visibility: hidden; the visibility change is delayed until the slide-out transition finishes, so the panel animates out smoothly and its links leave the tab order. Inside the drawer, .od-link items use aria-current="page" for the active entry, .od-badge shows counts and .od-user sticks to the bottom with margin-top: auto.
Customization
checkedon.od-toggle: the demo starts with the drawer open; remove the attribute to start closed.--od-widthon.od-shell: drawer width, e.g.360pxfor a wider panel (it never exceeds 86% of the shell).--od-speed: duration of the slide, fade and burger animation, e.g.0.2sfor a snappier drawer.--od-accentand--od-accent-soft: the violet used for the active link, badges, the Menu button and focus rings.--od-scrim: color and opacity of the overlay, e.g.rgba(0, 0, 0, 0.6)for a darker backdrop.--od-height: minimum height of the demo shell; set it to100vhfor a full-page app layout.- To open from the right, change
left: 0toright: 0on.od-drawerandtranslateX(-100%)totranslateX(100%).
Use cases
- Mobile app navigation: a Menu button slides in a panel with icons and count badges, no scripts needed
- Admin dashboards: the drawer works as a sidebar with a team list and a user card pinned at the bottom
- Filter panels on shops: a slide-in panel with a dimmed scrim keeps the product page clean until needed
- Script-free sites: pages that must avoid JavaScript still get an animated burger icon and smooth slide-out
Accessibility
The checkbox is visually hidden but stays in the tab order, so keyboard users reach it with Tab and toggle it with Space. Its label "Menu" gives it an accessible name, aria-controls points to the drawer, and a 3px outline appears around .od-burger when the checkbox has :focus-visible. The drawer is a nav with aria-label, the team list is labelled by its heading, and the decorative scrim and icons are aria-hidden. Because a closed drawer is visibility: hidden, screen readers and the Tab key skip its links. Under prefers-reduced-motion the drawer, scrim and burger switch instantly.
Usage notes
A CSS-only drawer cannot close on the Escape key or move focus automatically; add a small script if you need those. For a full-page layout, switch .od-drawer and .od-scrim from position: absolute to position: fixed. Give each extra instance its own checkbox id.