compacto-ui

Search documentation

Jump to a page or a component.

Sidebar

The rail-plus-pane shell both apps hand-roll: a 48px icon strip that selects a full-height pane.

server-safe

Preview

texture

Requests

All
3 items
Profile service

Installation

No install — ask an AI agent to copy this component from registry.json.

import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarHeader, SidebarItem, SidebarRail, SidebarRailButton, SidebarRailSpacer, SidebarRailTablist, SidebarSeparator, SidebarTitle } from "@/components/ui/sidebar";

Notes

  • Server-safe — no hooks and no state of its own. The parts that take an onClick put the client boundary in your file, not ours.
  • Two halves. The rail is the 48px icon strip that selects a section; the pane is the full-height column it selects. They are separate components because plenty of layouts want one without the other.
  • The pane carries no chrome of its own — compose SidebarHeader, SidebarContent and SidebarFooter inside it. Same reasoning as DialogContent: keeping padding and dividers in the parts is what makes every instance read as the same object.
  • The rail button's active marker grows from zero height rather than appearing at full size, so switching sections never nudges the icon beside it.
  • data-active is a styling hook and says nothing to a screen reader. When a rail button is a tab, set aria-selected and aria-controls alongside it, and give the pane role="tabpanel" with a matching id.
  • SidebarRail renders a <nav>, so give it an aria-label — on a page with more than one navigation landmark an unnamed one is indistinguishable from the rest.
  • Only the controls that switch the shared pane belong in SidebarRailTablist. A button that opens a dialog or signs you out is not a tab; leave it a loose child.
  • SidebarHeader is 48px, the same height as the rail's first control, so the two line up across the seam.
  • SidebarItem renders a <button type="button">. Inside a form the default would be "submit", which would post the form on every row click.
  • Pass side="right" to both SidebarRail and its buttons for a rail on the trailing edge — the border and the state markers both flip.
  • The pane fills its parent edge to edge, so it drops straight into a ResizablePanel.
  • texture draws a decorative wash — checker, dots or graph — on a ::before behind the content, from the active palette's accent. It is what makes a side panel read as a distinct layer rather than flat filler.
  • SidebarHeader and SidebarFooter paint flat above the wash (they carry relative and an opaque background), so the pattern belongs to the content area, not the chrome. Leave the rail flat too — a flat strip beside a textured pane is what makes the pane read as a surface — and never texture the work area.
  • Texture strength is --app-texture-alpha (default 0.05). Set it on an ancestor to tune one panel, on :root to tune all of them — the apps expose it as a user setting.

Props

The props worth knowing. Everything else passes straight through to the underlying element, including className, which is merged last so it always wins.

PropTypeDefaultDescription
side (Rail, RailButton)"left" | "right""left"Which edge the rail sits on, and which side its state markers point from. Pass the same value to both.
texture (Rail, Sidebar)"none" | "checker" | "dots" | "graph""none"Decorative wash over the surface, drawn from the palette accent at --app-texture-alpha.
size (RailButton)"default" | "sm""default"36px, or 32px for a denser rail.
asChild (RailButton, Item)booleanfalseRender the caller's child element instead of a <button> — for a control that is really a link.
data-active (RailButton)boolean—Marks the current control: drives the tint and the edge marker. Pair with aria-selected when it is a tab.
data-selected (Item)boolean—Marks the current row. Uses the same treatment as every other selectable row in the system.