Skip to content

Drawer ​

catnip-drawer opens as a native modal dialog. Focus moves in, stays inside, and returns to the trigger after close, and the page behind is inert. You provide the accessible name and, optionally, a description.

Keyboard ​

KeyBehaviour
Tab / Shift + TabMoves between the drawer's controls; Tab stays within the modal.
EscapeRequests dismissal when closable is true. You close the drawer by updating open (see Controlled dismissal). While a tooltip inside the drawer is showing, the first Escape closes only the tooltip.
  • On open, focus moves into the drawer: an autofocus descendant when there is one, otherwise the first available action, with the drawer itself as the fallback.
  • Focus containment is native. A fallback Tab trap is used when native modal opening is unavailable.
  • After closing, focus returns to the previously focused element.
  • Backdrop dismissal remains opt-in.

Screen readers ​

  • Opens with showModal(), exposes role="dialog" and aria-modal="true", and makes the page behind it inert.
  • Native dialog semantics announce the drawer's role, name, and optional description when focus enters. An aria-live region is intentionally not added because it would duplicate that announcement.
  • The icon-only close button is named by closeButtonAriaLabel (default "Close drawer").

What you own ​

  • Accessible name: Every drawer needs one. Provide drawerAriaLabel when the visible header cannot be referenced reliably across the custom element's shadow boundary. Use ariaLabelledby when the referenced relationship is supported and verified in the consuming framework and browser matrix; it takes precedence over drawerAriaLabel.
  • Description: Connect optional supporting text with ariaDescribedby when appropriate.
  • Initial focus: Place autofocus on the most useful initial control only when focusing it will not unexpectedly scroll past important introductory content.
  • Announcements: Do not add aria-live to the drawer: doing so can announce the same content twice. Use live regions inside the body only for genuinely dynamic status updates that occur after the drawer opens.
  • Stacked modals: If another modal must open over the drawer, ensure only the topmost modal accepts interaction and restore focus in the correct order.

Catnip Design System by Signicat