Drawer Dialog
Slide-in panel using native <dialog> element. Side drawers for navigation, settings, or detail views.
Overview
A drawer is a dialog that slides in from the side of the screen. It uses the native <dialog> element for built-in accessibility (focus trapping, escape key, backdrop). CSS handles the slide animation with @starting-style for entry transitions.
Key features:
- Native
<dialog>with focus trapping and escape key - Slides from left (
start) or right (end) - CSS animation with
@starting-style - Full-height panel with scrollable body
Basic Drawer
A right-side drawer with header, scrollable body, and footer actions.
Drawer Styles
Add these styles to your project. The data-position attribute controls which side the drawer slides from.
Navigation Drawer
A left-side drawer for mobile navigation. Use data-position="start" for conventional left-side navigation.
Usage Notes
- Position: Use
data-position="end"for settings/details,data-position="start"for navigation - Width: Adjust
max-widthin the CSS (default:min(90vw, 400px)) - Scrolling: The
.drawer-bodyscrolls independently withoverflow-y: auto - Click outside: Add a click listener on the dialog for backdrop dismissal
- Animation: Uses
@starting-stylefor entry animation. Respectsprefers-reduced-motion
Related
Dialog Element
Native dialog documentation
Modal Dialog
Centered modal patterns