Skip to Content
zjkm-ui
Components

Drawer Sidebar

A sidebar that slides in over the page.

Props
<DrawerSidebar items={items} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/drawer-sidebar.json
import { 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

PropTypeDefaultDescription
items{ label, href }[]The links.
currentstringThe current page's href.
titlestring"Menu"Heading and accessible name.
classNamestringClasses for the dialog.

With reduced motion, the drawer appears without sliding.

On this page