[ Overlays ]
Drawer
A panel that slides in from an edge of the screen and slides back out when closed. It shares all of Modal's behaviour (focus trap, scroll lock, Escape to close) and adds placement, size and a floating style with rounded corners. Bottom sheets get a grab handle.
Import#
import { Drawer } from 'reusify-ui';When to use#
- Filters, settings and detail views that keep the main page in context.
- Mobile navigation menus (placement="left").
- Longer forms that would feel cramped in a Modal.
Examples#
Filters panel#
Placement & size#
size accepts sm (20rem), md (24rem), lg (32rem) or any CSS length. It sets the width for left/right and the height for top/bottom.
<Drawer placement="left" … />
<Drawer placement="right" size="lg" … />
<Drawer placement="top" size="16rem" … />
<Drawer placement="bottom" size={300} … />Floating#
floating insets the drawer from every edge and rounds all its corners, like a card sliding in. It works with every placement. Close it to see the exit animation.
<Drawer floating placement="right" open={isOpen} onClose={close} title="Notifications" … />
<Drawer floating placement="bottom" size="18rem" open={isOpen} onClose={close} title="Share" … />API reference#
<Drawer />
Accepts every Modal prop except size, plus:
| Prop | Type | Default | Description |
|---|---|---|---|
placement | 'left' | 'right' | 'top' | 'bottom' | 'right' | Edge the drawer slides in from. |
size | 'sm' | 'md' | 'lg' | string | number | 'md' | Width (left/right) or height (top/bottom). Numbers are pixels. |
floating | boolean | false | Inset from the edges with fully rounded corners. |
open* | boolean | - | Whether the drawer is visible. |
onClose* | () => void | - | Called on Escape, overlay click or the close button. |
title / description / footer | ReactNode | - | Same as Modal. |
placement'right''left' | 'right' | 'top' | 'bottom'Edge the drawer slides in from.
size'md''sm' | 'md' | 'lg' | string | numberWidth (left/right) or height (top/bottom). Numbers are pixels.
floatingfalsebooleanInset from the edges with fully rounded corners.
open*-booleanWhether the drawer is visible.
onClose*-() => voidCalled on Escape, overlay click or the close button.
title / description / footer-ReactNodeSame as Modal.
Accessibility#
- Same as Modal: role="dialog", focus trap, scroll lock and focus restore.
- Enter and exit slides are turned off when the user prefers reduced motion.