Ballmac UI home

Sidebar

An app sidebar with icon-rail collapse, floating and inset variants, grouped menus with badges and sub-items, a mobile sheet, tooltips when collapsed and a Cmd/Ctrl+B shortcut.

7/7 checksv1.0.1Updated Oct 11, 2026Ships with a test
What changed
  1. 1.0.1 Oct 11, 2026Control heights, menu and sidebar row sizes, press dimming and frosted surfaces follow the platform feel tokens (--bm-control-h, --bm-menu-*, --bm-sidebar-*, --bm-material-*). Unchanged without a feel.
  2. 1.0.0 Sep 30, 2026First release.

Update without losing your edits

Home

Collapse with the button or press ⌘B (Ctrl+B).

Installation

The default, and what a Radix-style project installs.

$ pnpm dlx shadcn@latest add @ballmac/sidebar

Usage

import { Sidebar, SidebarProvider, SidebarTrigger, SidebarInset, SidebarHeader, SidebarFooter, SidebarContent, SidebarSeparator, SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarMenuBadge, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton, useSidebar } from "@/components/ballmac/sidebar"

The full example is in the Code tab above.

Examples

Icon rail, floating

Hover or focus an icon to see its name.

API reference

<SidebarProvider>

PropTypeDefault
defaultOpen

Initial open state when uncontrolled.

booleantrue
open

Controlled open state (desktop).

boolean—
onOpenChange

Called when the desktop sidebar opens or closes, for example to save the choice in a cookie.

(open: boolean) => void—
shortcut

Key that toggles the sidebar together with ⌘ (Ctrl on Windows and Linux). `false` turns the shortcut off.

string | false"b"

<Sidebar>

PropTypeDefault
side

Which edge the sidebar sits on. `start` (the default) and `end` follow the reading direction; `left` and `right` are fixed.

"start" | "end" | "left" | "right""start"
variant

`sidebar` is flush, `floating` is a rounded card with a gap, `inset` pairs with `SidebarInset`.

"sidebar" | "floating" | "inset""sidebar"
collapsible

`icon` collapses to an icon rail, `offcanvas` slides away, `none` is always open.

"offcanvas" | "icon" | "none""icon"
label

Accessible name of the navigation landmark (and of the mobile sheet).

string—

<SidebarMenuButton>

PropTypeDefault
href

Link target. When set the button renders as an `<a>`; add `aria-current="page"` via `isActive`.

string—
asChild

Render the child (a router link) with button styles and behavior.

booleanfalse
isActive

Highlight as the current page (sets `aria-current="page"` on links).

booleanfalse
tooltip

Tooltip text shown only while the sidebar is collapsed to icons. Defaults to the button's `aria-label`.

string—
size"default" | "sm" | "lg""default"

<SidebarMenuSubButton>

PropTypeDefault
isActivebooleanfalse

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Cmd/Ctrl+BToggles the sidebar
TabMoves through links; the current page has aria-current
MobileOpens as a named dialog sheet; Escape closes

Quality scorecard

7/7

Every applicable check passes

Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.1, across 2 examples.

How we measure
  • Passed: Accessibility scan

    No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).

  • Passed: Small screens

    No sideways scrolling at 360, 390 or 1280 px wide.

  • Passed: Reduced motion

    No endless animation to begin with.

  • Passed: Right to left

    Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).

  • Passed: Clean console

    No console errors or React hydration errors while loading.

  • Passed: Keyboard

    11 tab stops, each showing a visible change when it takes focus. 3 documented keys.

  • Not applicable: Loading, empty and error

    Does not show data or take submissions.

  • Passed: Automated tests

    Covered by sidebar.test.tsx.

  • For information: Footprint

    4.9 KB of source (gzip) in 1 file. Installs class-variance-authority, radix-ui, lucide-react.

Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.

Use with AI

SidebarProvider wraps Sidebar and SidebarInset. Menu entries use SidebarMenuButton with href and isActive. SidebarTrigger toggles it. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Sidebar (@ballmac/sidebar) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Application navigation with many sections
  • Dashboards and admin tools

Not for

  • Marketing site headers; use navigation-menu
  • Two or three links; use tabs

Registry JSON: https://ui.ballmac.com/r/sidebar.json

Credits

Based on shadcn/ui Sidebar, adapted by Ballmac. Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

311 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.