Overlays & Dialogs
@hacline/ui/drawerDrawer
A draggable overlay panel that slides out from the edge of the screen.
Usage
Open the delivery details, then dismiss via the close button, Escape, or dragging downward. Specify the screen edge with side and configure stop positions with snapPoints.
"use client";
import {
Drawer,
DrawerBackdrop,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerHandle,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/hacline/components/drawer";
export const Example = () => (
<Drawer side="bottom">
<DrawerTrigger>Open delivery details</DrawerTrigger>
<DrawerBackdrop />
<DrawerContent className="mx-auto max-w-lg rounded-b-none">
<DrawerHandle />
<DrawerTitle>Delivery details</DrawerTitle>
<DrawerDescription>
Packages arrive on weekdays between 09:00 and 18:00.
</DrawerDescription>
<DrawerClose>Close delivery details</DrawerClose>
</DrawerContent>
</Drawer>
);Opening from the Right
Set side="right" to display side panel details. Focus management and closing with Escape remain supported.
"use client";
import {
Drawer,
DrawerBackdrop,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/hacline/components/drawer";
export const Example = () => (
<Drawer side="right">
<DrawerTrigger>View members</DrawerTrigger>
<DrawerBackdrop />
<DrawerContent className="rounded-e-none">
<DrawerTitle>Project members</DrawerTitle>
<DrawerDescription>
Review users and permissions in this project.
</DrawerDescription>
<dl className="grid grid-cols-[1fr_auto] gap-2 text-sm">
<dt>Alice Lin</dt>
<dd>Maintainer</dd>
<dt>Noah Zhou</dt>
<dd>Viewer</dd>
</dl>
<DrawerClose>Close members</DrawerClose>
</DrawerContent>
</Drawer>
);Parts
| Part | Description | Extended Props |
|---|---|---|
DrawerBackdrop | A dim behind the drawer. Its opacity follows the drawer, so give it a color like bg-black/20. | variant |
DrawerClose | A button that closes the drawer. An action runs first, and a Promise it returns keeps the drawer open until it settles. | — |
DrawerContent | The sheet itself, a dialog. It renders inside a full-screen viewport the drawer positions it in. | — |
DrawerDescription | Describes the drawer while it's rendered. A paragraph by default. | — |
DrawerHandle | The grabber. Pressing it moves to the next snap point; arrow keys, Home and End step. Name it, like aria-label="Resize". | — |
DrawerOutlet | An element that follows the drawer, like the page behind it: it plays its keyframes as the drawer expands and gets the --drawer-* variables. Outside the drawer, pass the drawer's controller. | — |
DrawerShortcut | Shows a trigger's shortcut, like ⌘K, inside the trigger. Hidden from screen readers, which hear aria-keyshortcuts. | — |
DrawerTitle | The drawer's title, which names it. A level 2 heading by default. | — |
DrawerTrigger | The button that opens the drawer. A trigger outside the drawer, like one per table row, connects through controller. | — |
Props
Prop
Type