1. Components
  2. Overlays
  3. Drawer

Drawer

A drawer is an overlay element which blocks interaction with elements outside it.

<DialogRoot>
  <Button>Open drawer</Button>
  <Drawer>
    <DialogContent>Drawer content</DialogContent>
  </Drawer>
</DialogRoot>

Installation

npx dotui-cli@latest add drawer

Placement

The drawer can be placed on any edge of the screen using the placement prop: 'bottom', 'top', 'right', or 'left'.

Placement
<DialogRoot>
  <Button>Open drawer</Button>
  <Drawer placement={placement}>
    <DialogContent>Drawer content</DialogContent>
  </Drawer>
</DialogRoot>

API Reference

PropTypeDefaultDescription
placement'bottom' | 'top' | 'right' | 'left'-The drawer placement
isOpenboolean-Whether the overlay is open by default (controlled).
defaultOpenboolean-Whether the overlay is open by default (uncontrolled).
isDismissablebooleanfalseWhether to close the modal when the user interacts outside it.
UNSTABLE_portalContainerElementdocument.bodyThe container element in which the overlay portal will be placed. This may have unknown behavior depending on where it is portalled to.
isKeyboardDismissDisabledbooleanfalseWhether pressing the escape key to close the dialog should be disabled.
shouldCloseOnInteractOutside(element: Element) => boolean-When user interacts with the argument element outside of the overlay ref, return true if onClose should be called. This gives you a chance to filter out interaction with elements that should not dismiss the overlay. By default, onClose will always be called on interaction outside the overlay ref.
EventTypeDescription
onOpenChange(isOpen: boolean) => voidHandler that is called when the overlay's open state changes.
dotUI

Bringing singularity to the web.

Built by mehdibha. The source code is available on GitHub.