- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Drawer
A panel that slides in from the edge of the screen, with nested drawer support.
import { Button } from "@/components/ui/button";
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
export default function Particle() {
return (
<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>Open drawer</DrawerTrigger>
<DrawerContent>
<DrawerHeader className="text-center">
<DrawerTitle>Notifications</DrawerTitle>
<DrawerDescription>This is the description of the drawer.</DrawerDescription>
</DrawerHeader>
<DrawerFooter className="justify-center sm:justify-center">
<DrawerClose render={<Button variant="outline" />}>Close</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/drawer
Usage
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>Open</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Drawer Title</DrawerTitle>
<DrawerDescription>Drawer Description</DrawerDescription>
</DrawerHeader>
<div>Content</div>
<DrawerFooter>
<DrawerClose render={<Button variant="outline" />}>Close</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>API Reference
Built on Base UI's Dialog. Composition uses the render prop, not asChild — the same convention as Dialog, Alert Dialog and Sheet.
Drawer is a fixed slide-in panel, not a gesture surface: there is no swipe-to-dismiss and no snap points. Base UI's Dialog has no drag physics to build them on. If your project needs that interaction, compose it directly on top of a drag library — Drawer intentionally stays a thin, dependency-light wrapper around Base UI rather than reaching outside it for gesture support.
Drawer
Root component. All props from Base UI's Dialog.Root are supported, plus:
| Prop | Type | Default | Description |
|---|---|---|---|
direction | "top" | "bottom" | "left" | "right" | "bottom" | Controls which edge the drawer opens from and slides toward when closing |
DrawerTrigger
Trigger button that opens the drawer. All props from Dialog.Trigger are supported.
DrawerContent
Container that displays the drawer content. Renders the portal and the overlay internally, so DrawerPortal and DrawerOverlay do not need to be composed by hand. Sizing, rounding and borders follow the root's direction.
All props from Dialog.Popup are supported, plus a dark prop — see Sheet's SheetContent for what it does.
DrawerHeader
Container for the drawer title and description. Centers its text for top and bottom drawers, and left-aligns it from the md breakpoint.
DrawerFooter
Footer section for action buttons. Pushes itself to the bottom of the drawer.
DrawerTitle
Title component. Styled wrapper for Dialog.Title.
DrawerDescription
Description component. Styled wrapper for Dialog.Description.
DrawerClose
Close button component. All props from Dialog.Close are supported.
DrawerPortal
Portal component for rendering outside the DOM hierarchy. Styled wrapper for Dialog.Portal. Rendered internally by DrawerContent.
DrawerOverlay
Backdrop component. Styled wrapper for Dialog.Backdrop. Rendered internally by DrawerContent.
Examples
Right side drawer
import { Button } from "@/components/ui/button";
import {
Drawer,
DrawerContent,
DrawerDescription,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
export default function Particle() {
return (
<Drawer direction="right">
<DrawerTrigger render={<Button variant="outline" />}>Open drawer</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Notifications</DrawerTitle>
<DrawerDescription>This is the description of the drawer.</DrawerDescription>
</DrawerHeader>
<div>
<p className="text-muted-foreground text-sm">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris.
</p>
</div>
</DrawerContent>
</Drawer>
);
}
Directions
import { Button } from "@/components/ui/button";
import {
Drawer,
DrawerContent,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
export default function Particle() {
return (
<div className="flex flex-wrap gap-2">
<Drawer direction="right">
<DrawerTrigger render={<Button variant="outline" />}>Right</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Right</DrawerTitle>
</DrawerHeader>
<div>
<p className="text-muted-foreground text-sm">Content from the right.</p>
</div>
</DrawerContent>
</Drawer>
<Drawer direction="left">
<DrawerTrigger render={<Button variant="outline" />}>Left</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Left</DrawerTitle>
</DrawerHeader>
<div>
<p className="text-muted-foreground text-sm">Content from the left.</p>
</div>
</DrawerContent>
</Drawer>
<Drawer direction="top">
<DrawerTrigger render={<Button variant="outline" />}>Top</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Top</DrawerTitle>
</DrawerHeader>
<div>
<p className="text-muted-foreground text-sm">Content from the top.</p>
</div>
</DrawerContent>
</Drawer>
<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>Bottom</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Bottom</DrawerTitle>
</DrawerHeader>
<div>
<p className="text-muted-foreground text-sm">Content from the bottom.</p>
</div>
</DrawerContent>
</Drawer>
</div>
);
}
Scrollable content
import { Button } from "@/components/ui/button";
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
export default function Particle() {
return (
<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>Scrollable content</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Scrollable content</DrawerTitle>
</DrawerHeader>
<div>
<div className="flex flex-col gap-2">
{Array.from({ length: 48 }, (_, i) => `box-${i}`).map((key) => (
<div className="h-12 shrink-0 rounded-xl border bg-muted" key={key} />
))}
</div>
</div>
<DrawerFooter>
<DrawerClose render={<Button variant="outline" />}>Close</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}
Nested drawers
import { Button } from "@/components/ui/button";
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
export default function Particle() {
return (
<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>Nested drawers</DrawerTrigger>
<DrawerContent>
<DrawerHeader className="text-center">
<DrawerTitle>First step</DrawerTitle>
<DrawerDescription>
This is the first step. Tap the button below to continue to the next screen.
</DrawerDescription>
</DrawerHeader>
<DrawerFooter className="justify-center sm:justify-center">
<DrawerClose render={<Button variant="ghost" />}>Cancel</DrawerClose>
<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>Continue</DrawerTrigger>
<DrawerContent>
<DrawerHeader className="text-center">
<DrawerTitle>Second step</DrawerTitle>
<DrawerDescription>
You've reached the second step. Tap the button below to continue to the next
screen.
</DrawerDescription>
</DrawerHeader>
<div>
<div className="flex justify-center">
<div className="size-48 shrink-0 rounded-xl border bg-muted" />
</div>
</div>
<DrawerFooter className="justify-center sm:justify-center">
<DrawerClose render={<Button variant="ghost" />}>Back</DrawerClose>
<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>Continue</DrawerTrigger>
<DrawerContent>
<DrawerHeader className="text-center">
<DrawerTitle>Third step</DrawerTitle>
<DrawerDescription>
You've reached the final step. You can close this drawer or go back.
</DrawerDescription>
</DrawerHeader>
<div>
<div className="flex justify-center">
<div className="size-32 shrink-0 rounded-full border bg-muted" />
</div>
</div>
</DrawerContent>
</Drawer>
</DrawerFooter>
</DrawerContent>
</Drawer>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}
Nested side drawers
import { Button } from "@/components/ui/button";
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
export default function Particle() {
return (
<Drawer direction="right">
<DrawerTrigger render={<Button variant="outline" />}>Nested inset drawers</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Manage team member</DrawerTitle>
<DrawerDescription>View and manage a user in your team.</DrawerDescription>
</DrawerHeader>
<div className="grid gap-4">
<div className="grid gap-1">
<p className="text-muted-foreground text-sm">Name</p>
<p className="font-medium text-sm">Bora Baloglu</p>
</div>
<div className="grid gap-1">
<p className="text-muted-foreground text-sm">Email</p>
<p className="font-medium text-sm">bora@example.com</p>
</div>
</div>
<DrawerFooter>
<Drawer direction="right">
<DrawerTrigger render={<Button variant="outline" />}>Edit details</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Edit details</DrawerTitle>
<DrawerDescription>
Make changes to the member's information.
</DrawerDescription>
</DrawerHeader>
<div className="grid gap-4">
<Field>
<FieldLabel>Name</FieldLabel>
<Input defaultValue="Bora Baloglu" type="text" />
</Field>
<Field>
<FieldLabel>Email</FieldLabel>
<Input defaultValue="bora@example.com" type="email" />
</Field>
</div>
<DrawerFooter>
<DrawerClose render={<Button variant="ghost" />}>Cancel</DrawerClose>
<Button type="submit">Save changes</Button>
</DrawerFooter>
</DrawerContent>
</Drawer>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}
With a form
import { Button } from "@/components/ui/button";
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
export default function Particle() {
return (
<div className="flex flex-wrap gap-2">
<Drawer direction="right">
<DrawerTrigger render={<Button variant="outline" />}>Default footer</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Edit profile</DrawerTitle>
<DrawerDescription>
Make changes to your profile here. Click save when you're done.
</DrawerDescription>
</DrawerHeader>
<form className="contents">
<div className="grid gap-4">
<Field>
<FieldLabel>Name</FieldLabel>
<Input defaultValue="Margaret Welsh" type="text" />
</Field>
<Field>
<FieldLabel>Username</FieldLabel>
<Input defaultValue="@maggie.welsh" type="text" />
</Field>
</div>
<DrawerFooter>
<DrawerClose render={<Button variant="ghost" />}>Cancel</DrawerClose>
<Button>Save</Button>
</DrawerFooter>
</form>
</DrawerContent>
</Drawer>
<Drawer direction="right">
<DrawerTrigger render={<Button variant="outline" />}>Bare footer</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Edit profile</DrawerTitle>
<DrawerDescription>
Make changes to your profile here. Click save when you're done.
</DrawerDescription>
</DrawerHeader>
<form className="contents">
<div className="grid gap-4">
<Field>
<FieldLabel>Name</FieldLabel>
<Input defaultValue="Margaret Welsh" type="text" />
</Field>
<Field>
<FieldLabel>Username</FieldLabel>
<Input defaultValue="@maggie.welsh" type="text" />
</Field>
</div>
<DrawerFooter>
<DrawerClose render={<Button variant="ghost" />}>Cancel</DrawerClose>
<Button>Save</Button>
</DrawerFooter>
</form>
</DrawerContent>
</Drawer>
</div>
);
}
Mobile menu
import Link from "next/link";
import { Button } from "@/components/ui/button";
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
export default function Particle() {
return (
<Drawer direction="left">
<DrawerTrigger render={<Button variant="outline" />}>Open menu</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Menu</DrawerTitle>
</DrawerHeader>
<div>
<nav className="-mx-[calc(--spacing(3)-1px)] flex flex-col gap-0.5">
<DrawerClose
render={
<Button
className="justify-start"
nativeButton={false}
render={<Link href="#" />}
variant="ghost"
/>
}
>
Home
</DrawerClose>
<DrawerClose
render={
<Button
className="justify-start"
nativeButton={false}
render={<Link href="#" />}
variant="ghost"
/>
}
>
Profile
</DrawerClose>
<DrawerClose
render={
<Button
className="justify-start"
nativeButton={false}
render={<Link href="#" />}
variant="ghost"
/>
}
>
Settings
</DrawerClose>
<DrawerClose
render={
<Button
className="justify-start"
nativeButton={false}
render={<Link href="#" />}
variant="ghost"
/>
}
>
Sign out
</DrawerClose>
</nav>
</div>
</DrawerContent>
</Drawer>
);
}
Responsive dialog
Use Drawer on small screens and Dialog on larger ones to show the same content in a modal on desktop and a bottom sheet on mobile.
"use client";
import { useMediaQuery } from "@/hooks/use-media-query";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
const FORM_TITLE = "Edit profile";
const FORM_DESCRIPTION = "Make changes to your profile here. Click save when you're done.";
const TRIGGER_LABEL = "Open";
const CANCEL_LABEL = "Cancel";
const SAVE_LABEL = "Save";
const formFields = (
<>
<Field>
<FieldLabel>Name</FieldLabel>
<Input defaultValue="Margaret Welsh" type="text" />
</Field>
<Field>
<FieldLabel>Username</FieldLabel>
<Input defaultValue="@maggie.welsh" type="text" />
</Field>
</>
);
export default function Particle() {
const isMobile = useMediaQuery("max-md");
if (isMobile) {
return (
<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>{TRIGGER_LABEL}</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>{FORM_TITLE}</DrawerTitle>
<DrawerDescription>{FORM_DESCRIPTION}</DrawerDescription>
</DrawerHeader>
<form className="contents">
<div className="grid gap-4">{formFields}</div>
<DrawerFooter>
<DrawerClose render={<Button variant="ghost" />}>{CANCEL_LABEL}</DrawerClose>
<Button type="submit">{SAVE_LABEL}</Button>
</DrawerFooter>
</form>
</DrawerContent>
</Drawer>
);
}
return (
<Dialog>
<DialogTrigger render={<Button variant="outline" />}>{TRIGGER_LABEL}</DialogTrigger>
<DialogContent className="sm:max-w-sm">
<DialogHeader>
<DialogTitle>{FORM_TITLE}</DialogTitle>
<DialogDescription>{FORM_DESCRIPTION}</DialogDescription>
</DialogHeader>
<form className="contents">
<div className="grid gap-4">{formFields}</div>
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>{CANCEL_LABEL}</DialogClose>
<Button type="submit">{SAVE_LABEL}</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
}