A shadcn-style sidebar component built with Ark UI primitives.

Playground

Installation

npx shadcn@latest add @ark-cn/sidebar

Usage

import * as Sidebar from "@/components/ui/sidebar"

Read exported parts in src/components/ui/sidebar.tsx and compose the primitive according to the Ark UI pattern for this component.

The API surface and composition (provider, inset, groups, menu, rail, etc.) follow the same mental model as shadcn/ui’s Sidebar. For full-page layouts and copy-paste blocks, see the shadcn sidebar blocks (sidebar-01 … sidebar-16).

Examples

Previews use previewClassName so the layout is not squeezed into the default preview height (h-80), the shell fills the panel edge-to-edge, and the default preview panel border/background are removed (border-0 bg-transparent rounded-none).

Roughly matches shadcn sidebar-01 (“simple sidebar with navigation grouped by section”).

Data Fetching

Collapsible groups

Roughly matches shadcn sidebar-02 (collapsible sections).

Get Started

Nested submenus

Roughly matches shadcn sidebar-03 (submenus).

History

Floating variant

variant="floating" adds padding around the rail and a rounded, bordered surface. Similar to shadcn sidebar-04.

Explorer

Custom width

Set --sidebar-width on SidebarProvider (e.g. 19rem) like shadcn’s floating block example.

Custom width

Collapse to icons

collapsible="icon" — use tooltip on SidebarMenuButton for collapsed labels. See shadcn sidebar-07.

Icon mode (⌘/Ctrl+B)

Inset variant

variant="inset" with SidebarInset for the main column. See shadcn sidebar-08 (inset + secondary nav).

Inset layout

Right side

side="right" — render SidebarInset first, then Sidebar. See shadcn sidebar-14.

Right sidebar

Non-collapsible

collapsible="none" keeps a fixed-width rail (no off-canvas or icon collapse). See shadcn Sidebar props.

Platform
Fixed sidebar

Controlled open state

Use SidebarProvider with open and onOpenChange when an external control should drive the sidebar (desktop) or sheet (mobile). Same idea as shadcn’s controlled sidebar.

Controlled

API reference

This component mirrors the upstream Ark UI primitive. All props and DOM behavior are defined by Ark unless you see an ark-cn-only row below.

SidebarProvider

PropTypeDescription
defaultOpen?booleanUncontrolled initial open state (desktop).
open?booleanControlled open state.
onOpenChange?(open: boolean) => voidControlled callback.

Sidebar

PropTypeDescription
side?"left" | "right"Which edge the sidebar attaches to.
variant?"sidebar" | "floating" | "inset"Layout/visual variant.
collapsible?"offcanvas" | "icon" | "none"Collapse behavior.

SidebarMenuButton

PropTypeDescription
isActive?booleanSets data-active for selected styling.
tooltip?string | TooltipPopupPropsTooltip shown when sidebar is collapsed.
variant?"default" | "outline"Button style preset.
size?"default" | "sm" | "lg"Button size preset.

SidebarMenuAction

PropTypeDescription
showOnHover?booleanReveals the action only on row hover/focus.

See the ARK UI documentation for the full API.

This implementation is Ark UI–based but follows shadcn/ui’s Sidebar API and composition for props, context, and layout parts. For conceptual docs, props tables, and patterns (keyboard shortcut, useSidebar, theming, styling), use: