Charcoal UI

Sidebar

Collapsible app sidebar: width springs between 240 and 64 px, labels fade, and an ember bar marks the active item.

  • Category: Navigation
  • Licence: Free, MIT
  • Built with: React 19, Tailwind CSS 4, Motion
  • Dependencies: motion, clsx, tailwind-merge

Examples

Sidebar

API reference

PropTypeDefaultDescription
sections{ title?: string; items: { id, label, icon, badge? }[] }[]—
active / onSelectstring / (id: string) => void—
collapsed / defaultCollapsedboolean—
onCollapsedChange(collapsed: boolean) => void—
headerReactNode—

About Sidebar

Sidebar is the navigation rail for web apps: its width springs between full and icon-only, labels fade, and an accent bar marks the active item. It is the backbone of a dashboard layout.

Sidebar is a navigation component for React 19, styled with Tailwind CSS 4 and animated with Motion. It drops into Next.js, Vite, Remix or Astro through the shadcn CLI as a single file you own.

When to use Sidebar

  • SaaS dashboards and admin panels.
  • Email, chat and project apps.
  • Internal tools with many sections.
  • Docs with a collapsible navigation.

How it works

Width animates on a spring between 240 and 64 pixels while labels fade, and collapsed items keep tooltips and accessible names. The active bar is a shared layout element that slides between items.

Links and buttons keep their roles, arrow keys move where a group is expected, the current item is marked with aria-current, and focus is always visible. With prefers-reduced-motion on, it holds still or settles instantly instead of animating.

Customizing Sidebar

Every prop is documented in the API reference above with its type and default. The ones you will reach for first are listed here.

The Customize panel next to the preview lets you change header live, and the Code tab updates to match, so the snippet you copy already carries your values.

  • sections.
  • active / onSelect (string / (id: string) => void).
  • collapsed / defaultCollapsed (boolean).
  • header (ReactNode).

Goes well with Sidebar

These navigation pieces share its tokens and motion language, so they sit together on one page without clashing.

  • Tabs: Animated React tabs with a gliding indicator and panels that slide the way you travel
  • Breadcrumb: An animated React breadcrumb that folds long trails and unfolds them on click
  • Pagination: Animated React pagination with smart gaps and a pill that glides to the current page
  • Steps: Animated React steps for multi-step flows: filling connectors and drawn checks
  • Dropdown Menu: An animated React dropdown menu with icons, shortcuts, checkboxes and keyboard control

Install Sidebar

npx shadcn@latest add https://charcoalui.com/r/sidebar.json

Sidebar is free and MIT licensed. The command copies sidebar.tsx into components/ui and installs clsx, tailwind-merge; you can also copy the source from the Code tab by hand.

It pairs well with Dock, a Pro piece: macOS-style dock. Icons swell with pointer distance and show a label on hover.

Frequently asked questions

How do I install Sidebar?
Run npx shadcn@latest add https://charcoalui.com/r/sidebar.json. The shadcn CLI copies sidebar.tsx into components/ui and installs motion, clsx, tailwind-merge. You can also copy the source from this page by hand.
Is Sidebar free for commercial use?
Yes. Sidebar is MIT licensed: use it in any personal or commercial project and change it however you like.
Does Sidebar work with Next.js?
Yes. It is a client component for React 19 styled with Tailwind CSS 4, so it works in the Next.js App Router and Pages Router, Vite, Remix and Astro.
Can an AI coding agent install Sidebar?
Yes. Connect the Charcoal UI MCP server (https://charcoalui.com/mcp) to Claude Code, Cursor or any MCP client; get_component returns Sidebar's props and source and get_install_command returns the exact command.

Sidebar as Markdown · llms.txt