Components
Sidebar Overlay
A sidebar shown as a sheet on narrow screens.
Sidebar Overlay shows a sidebar's content as a modal sheet from the left or the right. The Calendar Sidebar and the Details Sidebar use it on phones. It's the same sheet as shadcn/ui's Sidebar on mobile, but you own its open state and the breakpoint, so a sidebar can turn into an overlay at any width.
Installation
pnpm dlx shadcn add @calendarcn/sidebar-overlayIt also adds the sidebars' color tokens to your CSS: see Colors.
Usage
import { SidebarOverlay } from "@/components/sidebar-overlay";
export function MobileNav() {
const [open, setOpen] = React.useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>Menu</Button>
<SidebarOverlay
open={open}
onOpenChange={setOpen}
side="left"
title="Navigation"
description="Pages of the app."
style={{ "--sidebar-width": "15rem" } as React.CSSProperties}
>
<nav>{/* ... */}</nav>
</SidebarOverlay>
</>
);
}The sheet is as wide as --sidebar-width, up to 85% of the screen. Its title and description are for screen readers only.
Features
- Closes on an outside tap and Esc, with focus kept inside while it's open.
- Opening focuses the sheet itself, not its first field, so a search field doesn't pop up a phone's keyboard.
- Works with shadcn/ui on Radix and on Base UI.
API Reference
SidebarOverlay
| Prop | Type |
|---|---|
open (required)Whether the sheet is open. | boolean |
onOpenChange (required)Called when the sheet asks to open or close. | (open: boolean) => void |
side (required)Edge the sheet slides in from. | "left" | "right" |
title (required)Accessible name of the sheet (visually hidden). | string |
description (required)Accessible description of the sheet (visually hidden). | string |
classNameClasses for the sheet. | string |
styleStyles for the sheet, e.g. its --sidebar-width. | CSSProperties |
CALENDAR_SIDEBAR_COLORS_CLASS points shadcn/ui's --sidebar-* colors at the --calendar-sidebar-* tokens for an element and what's inside it. The sheet and both calendar sidebars use it.