Skip to content
Ballpoint

Sidebar

An app's sidebar: it folds away or to icons, becomes a sheet on a phone and toggles from anywhere with ⌘B. Its edge is ruled by hand, and the active page is shaded in with the pen.

From shadcn/ui
Home
Press ⌘B, or the button, to fold the sidebar away.

Installation

pnpm dlx shadcn@latest add @ballpoint/sidebar

Usage

tsx
import { Sidebar, SidebarContent, SidebarGroup, SidebarInset, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar"

<SidebarProvider>
  <Sidebar>
    <SidebarContent>
      <SidebarGroup>
        <SidebarMenu>
          <SidebarMenuItem>
            <SidebarMenuButton isActive render={<a href="/" />}>Home</SidebarMenuButton>
          </SidebarMenuItem>
        </SidebarMenu>
      </SidebarGroup>
    </SidebarContent>
  </Sidebar>
  <SidebarInset>
    <SidebarTrigger />
    …
  </SidebarInset>
</SidebarProvider>

Examples

Tooltips name each item while the sidebar is a strip of icons; the rail on its edge folds it too.

Folds to icons

A pencilled panel set off from the page, a badge, and a submenu in a Collapsible.

The page itself is the pencilled panel; skeletons stand in for items still loading.

Dashboard

The page is the pencilled panel, set in from the sidebar.

API reference

SidebarProvider defaultOpen / open / onOpenChange
default true
boolean

Open or folded, controlled or not.

SidebarProvider contained
default false
boolean

Keep the sidebar inside its box instead of the window, for a demo or a panel within a page.

Sidebar side
default "left"
"left" | "right"

Which edge it sits on.

Sidebar variant
default "sidebar"
"sidebar" | "floating" | "inset"

An edge ruled by hand, a pencilled panel set off from the page, or the page as the pencilled panel.

Sidebar collapsible
default "offcanvas"
"offcanvas" | "icon" | "none"

Slides away, folds to a strip of icons, or stays open.

SidebarMenuButton isActive / tooltip / render
boolean / string | props / ReactElement

Shades the page you are on; names the item when the sidebar is folded to icons; renders your framework's link.

SidebarMenuButton variant / size
"default" | "outline" / "default" | "sm" | "lg"

Plain, or pencilled round; and its height.

useSidebar()
{ state, open, setOpen, openMobile, setOpenMobile, isMobile, toggleSidebar }

Read and change the sidebar from anywhere inside the provider.

keyboard
⌘B or Ctrl+B

Toggles the sidebar, or its sheet on a phone.

Pen settings

The drawing also takes draw, roughness, passes, radius, corners, shadow, weight and speed, as props or from the nearest InkProvider. What each one does.