Skip to content

Drawer ​

catnip-drawer is a modal, end-side panel for focused tasks that need more vertical space than a Dialog, such as editing details, reviewing records, or completing a multi-field form.

It renders with the native <dialog> element and uses a controlled open state. Consumers compose all visible content through the header slot, the default body slot, and the footer slot; the Drawer does not prescribe heading or footer-action APIs. Grid-aligned widths are s = 492px, m = 578px, and l = 664px. --catnip-drawer-width overrides the t-shirt size on desktop.

Live example ​

Guidelines ​

When to use ​

  • Use Drawer for a focused modal task that benefits from full viewport height or requires the user to retain some visual context of the underlying page.
  • Use Dialog for short decisions and compact forms that work better in a centered surface.
  • Use a persistent sidebar or page layout—not Drawer—for primary navigation or content that should remain available while users interact with the page.

Composition ​

Compose the entire visible anatomy through the header slot, the default body slot, and the footer slot. Consumers own headings, supporting copy, footer controls, button hierarchy, validation, and action handlers. The Drawer owns only the modal shell, optional close button, scrolling regions, focus behavior, and dismissal requests.

The body is the only scrolling region. Keep the title, close action, and footer actions visible while long content scrolls.

Controlled dismissal ​

Treat open as the source of truth. The close button, Escape, and enabled backdrop dismissal emit close-drawer and update:open=false; consumers close the drawer by updating open. Slotted footer actions are consumer-owned and should update open directly when their work permits closing.

Backdrop dismissal is off by default to protect in-progress forms from accidental pointer input. Keep Escape available for ordinary tasks. Use closable=false only when dismissal would be unsafe, and always retain an obvious explicit path through the close button or a consumer-provided footer action.

If the drawer contains unsaved work, handle the close request in the consuming application and present a confirmation flow before changing open.

Avoid opening a Drawer on top of another modal. If a confirmation is required, prefer an in-drawer confirmation state; see Accessibility for stacked-modal focus duties.

Catnip overlays inside the drawer (Tooltip, Dropdown, Date, Phone country list, Tabs overflow menu) teleport into the open <dialog> — not document.body. Modal showModal() makes everything outside that subtree inert, so a body portal cannot paint or receive pointer events above the drawer.

Responsive behavior ​

Use size="s" (492px), size="m" (578px), or size="l" (664px). Large is the default. These widths align to the Drawer layout grid. Choose the size from the task's expected structure rather than allowing content to determine the width; content-driven sizing causes layout shifts and inconsistent wrapping.

For exceptional layouts, set --catnip-drawer-width on the host. This overrides the selected desktop size but remains capped at the viewport width:

css
catnip-drawer {
  --catnip-drawer-width: 720px;
}

At the mobile breakpoint the drawer always becomes full viewport width, including when a custom width is set. Content wraps or scrolls inside the body and never expands the drawer. Keep primary actions concise so the footer can wrap without obscuring body content.

Catnip Design System by Signicat