Skip to main content

Basic

A panel that slides in from the edge and covers the page with a backdrop. It has the same behaviour as a modal: button-text or button-icon renders the button, or one of your own goes in the button slot with aria-haspopup="dialog" and aria-controls (<id>-panel; button-class adds classes to the default button), the popup script makes the panel a modal dialog while it is open, traps Tab, closes on Esc or a click on the backdrop and returns the focus to the button. A button inside the panel with the same aria-controls closes it. The header names the dialog with aria-labelledby.

Custom header

The header slot replaces the title; the close button stays, and title becomes the aria-label of the dialog.

Placement

From the right (the default, for details and forms), the left (navigation), the top or the bottom (a sheet on a phone). Only the position classes and the translate classes change.

Sizes

The panel is w-full with a maximum: max-w-sm, max-w-md or max-w-2xl. On a phone every size fills the screen.

Filters form

A form in a drawer keeps the list visible behind the backdrop. The body scrolls on its own, so the header and the buttons stay in view. Every field has a visible label; the first focusable control (the close button) receives the focus when it opens.

Options reference

No script of its own: the popup script of the page handles the dialog.

Part Value Description
Trigger aria-haspopup="dialog", aria-controls, aria-expanded The popup script opens and closes the drawer and keeps aria-expanded.
Backdrop invisible → has-[>[aria-modal=true]]:visible Fades in with the drawer. A click on it closes the drawer.
Panel <id>-panel, aria-labelledby Gets role="dialog" and aria-modal while open.
Placement right, left, top, bottom Position classes plus translate-x-full or translate-y-full when closed.
Size max-w-sm, max-w-md, max-w-2xl Maximum width of a side drawer.
Closer button with the same aria-controls Inside the panel: the X in the header, Cancel, Save.
Motion motion-reduce:transition-none No slide for people who ask for less motion.