Skip to main content

Drawer

A modal side sheet for connect flows and create forms.

Guidance​

Drawers are modal side sheets for work that needs more room than a dialog but should not leave the page: connecting an agent or a source (CLI and API snippets), or a create form. They slide in from the inline end by default (placement="start" or "bottom" for the others), on mm-raised with shadow-dialog over the same flat ink scrim as a dialog. Widths are sm (360px), md (--blade-w, 36rem, default) and lg (800px); full takes the viewport.

Behaviour is the dialog's: a native modal <dialog>, focus to the first autofocus element or the first control, Tab wraps, Escape and the close button fire a cancelable mm-request-close, focus returns to the opener and page scrolling is locked. The slide is a transform over --mm-dur-dialog (220ms), instant when opened from the keyboard and still under reduced motion. Placement follows the writing direction, so end is the left edge in right-to-left pages. Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/

Properties​

PropertyAttributeTypeDefaultDescription
placementplacementDrawerPlacement'end'Edge the drawer comes from: end (default, the inline end), start or bottom.
headingheadingstring''The heading, which also names the dialog. Required unless the heading slot is used.
descriptiondescriptionstring''A sentence under the heading, announced with it.
sizesizeDialogSize'md'sm (400px), md (560px, default), lg (800px) or full (the viewport less the page gutter).
openopenbooleanfalseOpens and closes the dialog. Reflects.
dismissibledismissiblebooleanfalseLets a click on the backdrop close the dialog (through mm-request-close). Leave off for forms.
headingLevelheading-levelnumber2Heading level for the outline, 1 to 6. The look does not change.
closeLabelclose-labelstring''Accessible name of the close button. Defaults to the close string.
alertalertbooleanfalseAnnounces the dialog as an alertdialog: an urgent interruption that needs a response, such as confirming a destructive action (mm-confirm-dialog sets it). Leave off for forms and tasks. Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/
returnValuestring''The value the dialog last closed with.

Methods​

MethodDescription
show()Opens the dialog.
close()Closes the dialog with an optional return value, which mm-close carries.
requestClose()Asks to close as Escape would: fires a cancelable mm-request-close and closes unless it is cancelled.

Events​

EventDetailDescription
mm-openCustomEvent<Record<string, never>>The drawer opened and focus moved into it.
mm-closeCustomEvent<DialogCloseDetail>The drawer closed.
mm-request-closeCustomEvent<DialogRequestCloseDetail>Escape, the close button or the backdrop asked to close. Cancel it to keep the drawer open.

Slots​

SlotDescription
DefaultThe body.
headingA rich heading, in place of the heading attribute.
descriptionA rich description, in place of the description attribute.
footerActions, primary last.

CSS parts​

PartDescription
dialogThe native dialog element.
headerThe header row.
headingThe heading.
descriptionThe description.
closeThe close button.
bodyThe scrolling body.
footerThe footer row.

Examples​

Every state of mm-drawer in Storybook, with keyboard and screen reader tests.