Overlay

Drawer

Side panel that slides in from the edge.

Available inreactangular

Preview

Live previewreal component

Install

TerminalBash
npx mcp-elements add drawer

Usage

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

PropTypeDefaultDescription
openbooleanControlled open state. Omit to use the internal useDrawer state
onOpenChange(open: boolean) => voidCalled 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.ReactNodeDrawer content, typically DrawerHeader / DrawerBody / DrawerFooter