Xzero UI
Pro library

Workspace sidebarPro

A product sidebar with a workspace switcher, live search, draggable favorites, and inline projects.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/workspace-sidebar
Live · keyboard ready

Variant: Workspace

A product sidebar with a workspace switcher, live search, draggable favorites, and inline projects.

Use this as the main navigation of a multi-workspace app. Load workspaces, favorites, and projects from your API, route through onNavigate, and persist order and new projects; creation in the preview is simulated.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/workspace-sidebar

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { WorkspaceSidebar } from "@/components/xzero/blocks/workspace-sidebar/workspace-sidebar";
import { useRouter } from "next/navigation";

export function AppNav() {
  const router = useRouter();

  return (
    <WorkspaceSidebar
      onNavigate={({ workspace, id }) => router.push(`/${workspace}/${id}`)}
      onCollapsedChange={(collapsed) => localStorage.setItem("rail", String(collapsed))}
    />
  );
}

API reference

WorkspaceSidebar

A product sidebar with a workspace switcher, live search, draggable favorites, inline project creation, and a collapsible icon rail. Workspaces, favorites, and projects are sample data.

PropTypeDefaultDescription
classNamestring–Extra class on the root element.
onNavigate(target: { workspace: string; id: string; name: string }) => void–Called when a favorite or project is opened. Connect it to your router.
defaultCollapsedbooleanfalseStart as the narrow icon rail.
onCollapsedChange(collapsed: boolean) => void–Called when the sidebar collapses or expands, from the toggle or the [ shortcut.

Keyboard interactions

KeysAction
[Toggles the icon rail when focus is not in a text field, menu, or dialog.
Alt+Arrow Up / DownMoves the focused favorite up or down.
EscapeClears the search, or cancels a new project name.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Related

Browse all components