Components
Drawer Sidebar
A sidebar that slides in over the page.
<DrawerSidebar items={items} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/drawer-sidebar.jsonimport { DrawerSidebar } from "@/components/drawer-sidebar"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
A menu button that slides a sidebar in over the page. It's a native modal <dialog>, so focus moves into it and stays there, Escape closes it, and the page behind can't be reached. Clicking the backdrop closes it too.
import { DrawerSidebar } from "@/components/drawer-sidebar";
export function MobileMenu({ path }: { path: string }) {
return <DrawerSidebar items={[{ label: "Home", href: "/" }, { label: "Inbox", href: "/inbox" }]} current={path} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | { label, href }[] | The links. | |
current | string | The current page's href. | |
title | string | "Menu" | Heading and accessible name. |
className | string | Classes for the dialog. |
With reduced motion, the drawer appears without sliding.