Sidebar

A composable, themeable and customizable sidebar component.

Installation

pnpm add @notion-kit/ui

Anatomy

<SidebarProvider>
  <Sidebar>
    <SidebarClose />
    <SidebarHeader>{/* Your sidebar header */}</SidebarHeader>
    <SidebarContent>{/* Your sidebar content */}</SidebarContent>
    <SidebarFooter>{/* Your sidebar footer */}</SidebarFooter>
    <SidebarRail />
  </Sidebar>
  <SidebarInset>{/* Your main content */}</SidebarInset>
</SidebarProvider>

Examples


Notion Sidebar

API Reference

SidebarProvider

PropTypeDefaultDescription
configPartial<SidebarConfig>-The configuration object of the sidebar.
defaultOpenboolean-The open state of the sidebar when it is initially rendered. Use when you do not need to control its open state.
openboolean-The (controlled) open state of the sidebar. Must be used in conjunction with onOpenChange.
onOpenChange(open: boolean) => void-Handler that is called when the open state of the sidebar changes.

Note

All the layout components below must be used within <SidebarProvider>.

A Sidebar extends the HTML <div> element. We list the extended properties only.

PropTypeDefaultDescription
side"left" | "right""left"The side of the sidebar.
variant"sidebar" | "floating""sidebar"The variant of the sidebar.
collapsible"offcanvas" | "none""offcanvas"Collapsible state of the sidebar.

SidebarHeader

A SidebarHeader extends the HTML <div> element.

SidebarContent

A SidebarContent extends the HTML <div> element.

SidebarFooter

A SidebarFooter extends the HTML <div> element.

SidebarGroup

A SidebarGroup extends the HTML <div> element.

SidebarInset

A SidebarInset extends the HTML <main> element.

SidebarRail

The SidebarRail is used to render a rail within a <Sidebar>. This rail can be used to toggle and resize the sidebar. It extends the HTML <div> element. We list the extended properties only.

PropTypeDefaultDescription
enableDragbooleantrueWhether the sidebar is draggable.

SidebarClose

The SidebarClose is used to close the sidebar. It can be triggered by keyboard shortcut. It extends the <Button> component.

SidebarOpen

The SidebarOpen is used to open the sidebar. It can be triggered by keyboard shortcut. It extends the <Button> component.

SidebarMenuItem

A SidebarMenuItem extends the HTML <div> element. We list the extended properties only.

PropTypeDefaultDescription
label*string-The title of the item.
hint*string-The tooltip of the item.
icon*LucideIcon-The displayed icon of the item.
shortcutstring-The keyboard shortcut of the item.

type SidebarConfig

The configuration object of the sidebar.

PropTypeDefaultDescription
defaultWidth*string248pxDefault width of the sidebar.
defaultModileWidth*string248pxDefault width of the sidebar on mobile.
minWidth*string248pxMinimum draggable width of the sidebar.
maxWidth*string400pxMaximum draggable width of the sidebar.
shortcut*string\Keyboard shortcut ⌘ + <shortcut> to toggle the sidebar.
cookieName*{ state: string, width: string }{ state: "sidebar:state", width: "sidebar:width" }Cookie names for sidebar state and sidebar width.
cookieMaxAge*number7dCookie's maximum lifetime (in seconds).