Overlay
Drawer
Side panel that slides in from the edge.
Available in
reactangularPreview
Live previewreal component
Install
TerminalBash
npx mcp-elements add drawerUsage
drawer-example.tsxTSX
import { Drawer, DrawerHeader, DrawerTitle, DrawerDescription, DrawerBody, DrawerFooter, Button } from '@mcp-elements/react'
import { useState } from 'react'
export function Example() {
const [open, setOpen] = useState(false)
return (
<>
<Button onClick={() => setOpen(true)}>Configure server</Button>
<Drawer open={open} onOpenChange={setOpen} side="right">
<DrawerHeader>
<DrawerTitle>Server settings</DrawerTitle>
<DrawerDescription>Edit connection details for filesystem-mcp.</DrawerDescription>
</DrawerHeader>
<DrawerBody>Endpoint, scopes, and environment variables go here.</DrawerBody>
<DrawerFooter>
<Button variant="outline" onClick={() => setOpen(false)}>Cancel</Button>
<Button onClick={() => setOpen(false)}>Save</Button>
</DrawerFooter>
</Drawer>
</>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | — | Controlled open state. Omit to use the internal useDrawer state |
onOpenChange | (open: boolean) => void | — | Called when the open state should change (overlay click, Escape, close button) |
side | 'left' | 'right' | 'top' | 'bottom' | 'right' | Edge the drawer slides in from |
children * | React.ReactNode | — | Drawer content, typically DrawerHeader / DrawerBody / DrawerFooter |