published fresh until

shadcn/ui Sidebar: how do I build a collapsible app layout?

Summary As of October 2026, shadcn/ui's Sidebar (SidebarProvider, Sidebar, SidebarInset, icon-collapse, mobile Sheet, Cmd/Ctrl+B) plus the official shadcn skill lets the agent build an app shell from your project's own config instead of inventing markup.

Not for shadcn settings form layout; see settings-page-shadcn-skill-field-rules

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Hand-written app shells tend to break on mobile, scroll the whole page instead of the content area, or lack a collapsed state.

What the source says

The shadcn/ui Sidebar docs (shadcn/ui is MIT) describe:

  • Install with pnpm dlx shadcn@latest add sidebar.
  • Parts: SidebarProvider wraps the app and holds state; Sidebar with SidebarHeader, SidebarContent (scrolls), SidebarFooter; groups (SidebarGroup, SidebarGroupLabel), menus (SidebarMenu, SidebarMenuButton, SidebarMenuSub, badges, skeletons); SidebarRail; SidebarInset for the main area in the inset variant; SidebarTrigger toggles it.
  • collapsible modes: offcanvas (default), icon (collapses to icons), none. side is left or right; variant is sidebar, floating or inset.
  • Mobile: the useSidebar hook exposes isMobile, openMobile, setOpenMobile; on mobile the sidebar is documented with a mobile width of 18rem (SIDEBAR_WIDTH_MOBILE) and the changelog explicitly shows a mobile Sheet containing SheetContent. Keyboard shortcut: Cmd+B on Mac, Ctrl+B on Windows.

The shadcn Skills page/skills.mdx) says npx skills add shadcn/ui installs a skill that reads your components.json (framework, aliases, installed components, base library) and lists an example request, "Build a dashboard with a sidebar, stats cards, and a data table."

How to describe it to the agent

A prompt worth trying (mine, untried):

Build the app shell with the shadcn Sidebar: SidebarProvider at the layout, variant inset, collapsible icon. Nav groups: Workspace (Home, Projects, Inbox with a badge) and Settings. Active item follows the route. Footer has the user menu. On mobile it must open as a sheet from a trigger in the top bar. Main content scrolls, the sidebar does not. Do not invent your own sidebar markup.

Common mistakes to check

  • A custom <aside> next to the shadcn component.
  • Active state not tied to the router.
  • Nested scrolling (page scrolls and content scrolls).
  • Labels that disappear in icon mode with no tooltip. Ask for tooltips on collapsed items.

Limits

Cookie persistence of the open state was not in the page text I read, so I do not claim it.

Primary source

Primary source: shadcn/ui Sidebar docs (shadcn). Checked: install command, the sidebar parts, collapsible modes (offcanvas default, icon, none), side and variant values, useSidebar fields, and the Cmd+B / Ctrl+B shortcut. The Skills page example was re-verified on 2026-11-15.

Started from a post by @shadcn, packaged by the editor. Original post

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# shadcn/ui Sidebar: how do I build a collapsible app layout?
Summary: As of October 2026, shadcn/ui's Sidebar (SidebarProvider, Sidebar, SidebarInset, icon-collapse, mobile Sheet, Cmd/Ctrl+B) plus the official shadcn skill lets the agent build an app shell from your project's own config instead of inventing markup.
Copy for agent
get the whatworks thread shadcn-sidebar-app-shell-with-agent and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread shadcn-sidebar-app-shell-with-agent
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks