Drawer

Drawer is a component for a panel that appears from the edge of the screen.

Usage

import { Drawer } from "@yamada-ui/react"
<Drawer.Root>
  <Drawer.OpenTrigger />
  <Drawer.Content>
    <Drawer.Overlay />
    <Drawer.CloseButton />
    <Drawer.Header />
    <Drawer.Body />
    <Drawer.Footer />
    <Drawer.CloseTrigger />
  </Drawer.Content>
</Drawer.Root>

Change Size

Change Position

To change the display position, set placement to values like "block-start" or "inline-start". By default, "inline-end" is set.

Change Duration

To change the duration, set duration to a numerical value (seconds).

Do Not Block Scroll on Mount

By default, scrolling of the main content is blocked when the panel is opened to ensure accessibility. If you do not want to block the scroll of the main content, set blockScrollOnMount to false.

Disable the Close Button

To disable the close button, set withCloseButton to false.

Disable the Overlay

To disable (hide) the overlay of the panel, set withOverlay to false.

Close on drag

If you want to close the Drawer on drag, set closeOnDrag to true.

Hide the Drag Bar

To hide the drag bar, set withDragBar to false.

Customize the Close Button

Customize the Overlay

Control

Use open and onClose to control the visibility.

Props

Accessibility

The Drawer follows the WAI-ARIA - Dialog (Modal) Pattern for accessibility.

Keyboard Navigation

When the Drawer opens, focus is trapped within it. That is, you cannot focus on elements outside the modal unless the modal is closed.

KeyDescriptionState
TabFocuses the next element inside the modal that is not disabled. If it's the last element, focuses the first element that is not disabled.open={true}
Shift + TabFocuses the previous element inside the modal that is not disabled. If it's the first element, focuses the last element that is not disabled.open={true}
EscapeCloses the modal.open={true} + closeOnEsc={true}

ARIA Roles and Attributes

ComponentRoles and AttributesUsage
Drawer.Contentrole="dialog"Indicates that it is a dialog.
aria-modal="true"Indicates that the displayed widget is modal.
aria-labelledbySets the id of the associated Drawer.Title.
aria-describedbySets the id of the associated Drawer.Body.
Drawer.OpenTriggeraria-expandedSets to "true" when modal is opened, and "false" when it is closed.
aria-controlsSets the id of the Drawer.Content when open, and is not set when closed.
aria-haspopup="dialog"Indicates that a dialog exists.
aria-labelSets to "Open modal".
Drawer.CloseButtonaria-labelSets to "Close modal".
Drawer.CloseTriggeraria-labelSets to "Close modal".
Drawer.Overlayaria-hidden="true"Excludes the element from the accessibility tree.