Drawer
A panel that slides out from the edge of the screen.
When To Use
- Use a Form to create or edit a set of information.
- Processing subtasks. When subtasks are too heavy for Popover and we still want to keep the subtasks in the context of the main task, Drawer comes very handy.
- When a same Form is needed in multiple places.
Basic
Basic drawer.
astro
---
import Drawer from '@/components/feedback/Drawer.astro';
import Button from '@/components/general/Button.astro';
---
<Button onclick="window.Drawer.open('demo-drawer')">Open</Button>
<Drawer id="demo-drawer" title="Basic Drawer">
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer> Custom Placement
Use the `placement` prop to control which side the drawer slides from.
astro
---
import Drawer from '@/components/feedback/Drawer.astro';
import Button from '@/components/general/Button.astro';
---
<Button onclick="window.Drawer.open('demo-drawer-top')">top</Button>
<Button onclick="window.Drawer.open('demo-drawer-right')">right</Button>
<Button onclick="window.Drawer.open('demo-drawer-bottom')">bottom</Button>
<Button onclick="window.Drawer.open('demo-drawer-left')">left</Button>
<Drawer id="demo-drawer-top" placement="top" title="Basic Drawer">
<p>Some contents...</p>
</Drawer>
<Drawer id="demo-drawer-right" placement="right" title="Basic Drawer">
<p>Some contents...</p>
</Drawer>
<Drawer id="demo-drawer-bottom" placement="bottom" title="Basic Drawer">
<p>Some contents...</p>
</Drawer>
<Drawer id="demo-drawer-left" placement="left" title="Basic Drawer">
<p>Some contents...</p>
</Drawer> API Reference
| Property | Description | Type | Default |
|---|---|---|---|
| id | A unique identifier for the drawer, required for opening/closing. | string | - |
| title | Optional title text for the drawer header. | string | - |
| description | Optional description text displayed below the title. | string | - |
| placement | The edge of the screen the drawer slides from. | 'left' | 'right' | 'top' | 'bottom' | 'right' |
| closable | If true, shows a close button and allows closing via backdrop click. | boolean | true |
| resizable | If true, allows the user to drag the edge to resize the drawer. | boolean | false |