# Sidebar

Collapsible workspace navigation with an inline mobile menu.

Access: pro. Category: Navigation. Kind: composite.

## When to use

- Use it when a page needs collapsible workspace navigation with an inline mobile menu.
- Choose it as the nav region when composing a page from independently reusable TidalUI sections.

## Alternatives

- Choose navigation-bar instead when responsive saas navigation with native links, actions and an in-flow mobile disclosure is the actual interface need, rather than sidebar.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Sidebar

```sh
npx shadcn@latest add @tidal-pro/sidebar
```

Stylesheets: `components/ui/tidal.css`, `components/ui/sidebar.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/sidebar.css";
import{TidalSidebar}from"./components/ui/sidebar";
export default()=><div className="tidal-scope"><TidalSidebar navigation={"value"} title={"Demo"}/></div>;
```

## Structured props

- `TidalSidebar.navigation: ReactNode`: Required navigation value accepted by this exported component.
- `TidalSidebar.title: string`: Required title value accepted by this exported component.
- `TidalSidebar.collapsed?: boolean | undefined`: Optional collapsed value accepted by this exported component.
- `TidalSidebar.defaultCollapsed?: boolean | undefined` (default false): Optional default collapsed value accepted by this exported component.
- `TidalSidebar.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalSidebar.mark?: ReactNode`: Optional mark value accepted by this exported component.
- `TidalSidebar.navigationLabel?: string | undefined` (default "Workspace"): Optional navigation label value accepted by this exported component.
- `TidalSidebar.onCollapsedChange?: ((collapsed: boolean) => void) | undefined`: Callback invoked when the collapsed change interaction is proposed.
- `TidalSidebarGroup.label: string`: Required label value accepted by this exported component.
- `TidalSidebarLink.label: string`: Required label value accepted by this exported component.
- `TidalSidebarLink.active?: boolean | undefined` (default false): Optional active value accepted by this exported component.
- `TidalSidebarLink.badge?: string | number | undefined`: Optional badge value accepted by this exported component.
- `TidalSidebarLink.icon?: ReactNode`: Optional icon value accepted by this exported component.
- `TidalSidebarAction.label: string`: Required label value accepted by this exported component.
- `TidalSidebarAction.active?: boolean | undefined` (default false): Optional active value accepted by this exported component.
- `TidalSidebarAction.badge?: string | number | undefined`: Optional badge value accepted by this exported component.
- `TidalSidebarAction.closeOnSelect?: boolean | undefined` (default true): Optional close on select value accepted by this exported component.
- `TidalSidebarAction.icon?: ReactNode`: Optional icon value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/sidebar.tsx) | [Manifest](https://tidalui.com/examples/sidebar.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useState } from "react";

import { LayoutGrid, Folder, Activity, Settings2, ArrowUpRight, ArrowDownLeft, Layers } from "lucide-react";

import { TidalSidebar, TidalSidebarAction, TidalSidebarGroup } from "./components/ui/sidebar";

import "./components/ui/sidebar.css";

function tidalExampleAvatarDataUri(seed: unknown) {
  const text = String(seed).replace(/[^a-z0-9]/gi, "").slice(-2) || "UI";
  const palette = ["#333333", "#555555", "#777777", "#999999", "#bbbbbb"];
  const color = palette[Array.from(text).reduce((sum, character) => sum + character.charCodeAt(0), 0) % palette.length];
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96"><rect width="96" height="96" rx="48" fill="${color}"/><circle cx="48" cy="38" r="17" fill="white" fill-opacity=".92"/><path d="M18 92c3-22 15-34 30-34s27 12 30 34" fill="white" fill-opacity=".92"/></svg>`;
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
}

function tidalExampleImageDataUri(label: string) {
  const safeLabel = label.replace(/[<>&]/g, "").slice(0, 28) || "Sample image";
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 675"><defs><linearGradient id="g" x1="0" x2="1" y1="0" y2="1"><stop stop-color="#171717"/><stop offset="1" stop-color="#555555"/></linearGradient></defs><rect width="1200" height="675" fill="url(#g)"/><circle cx="950" cy="100" r="260" fill="white" fill-opacity=".08"/><text x="80" y="570" fill="white" font-family="system-ui,sans-serif" font-size="64" font-weight="700">${safeLabel}</text></svg>`;
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
}

const tidalExampleStyles = ".tidal-scope .sidebar-specimen{width:100%;max-width:960px;box-shadow:0 24px 46px -32px #00000033;border-radius:var(--t-radius-card)}.tidal-scope .sidebar-demo-header{display:flex;justify-content:space-between;gap:12px;min-height:64px;align-items:center;padding:15px 24px;border-bottom:1px solid var(--t-border);font-size:11px;color:var(--t-muted)}.tidal-scope .sidebar-demo-header>span:last-child{font-size:11px;border:1px solid var(--t-border);border-radius:5px;padding:3px 6px}.tidal-scope .sidebar-demo-body{padding:28px;min-width:0}.tidal-scope .sidebar-demo-title{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:25px}.tidal-scope .sidebar-demo-title p{margin:0 0 5px;font-size:11px;letter-spacing:1px;color:var(--t-muted)}.tidal-scope .sidebar-demo-title h3{font-size:27px;font-weight:500;letter-spacing:-1px;line-height:1.2;margin:0}.tidal-scope .sidebar-demo-view-icon{display:grid;place-items:center;width:40px;height:40px;border-radius:50%;border:1px solid var(--t-border);color:var(--t-muted)}.tidal-scope .sidebar-demo-summary{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:25px}.tidal-scope .sidebar-demo-summary>span{display:flex;flex-direction:column;font-size:11px;color:var(--t-muted);gap:4px;border-top:1px solid var(--t-border);padding-top:15px}.tidal-scope .sidebar-demo-summary strong{font-size:30px;line-height:1.2;font-weight:400;color:var(--t-ink);letter-spacing:-1px}.tidal-scope .sidebar-demo-projects>header{display:flex;justify-content:space-between;font-size:11px;color:var(--t-muted);padding-bottom:8px}.tidal-scope .sidebar-demo-project{display:flex;align-items:center;gap:10px;min-width:0;padding:14px 0;border-top:1px solid var(--t-border)}.tidal-scope .sidebar-demo-project-icon{display:grid;place-items:center;width:33px;height:35px;flex:none;border:1px solid var(--t-border);border-radius:8px;background:var(--t-subtle);color:var(--t-muted)}.tidal-scope .sidebar-demo-project>span:nth-child(2){display:flex;flex-direction:column;flex:1;min-width:0;gap:3px}.tidal-scope .sidebar-demo-project strong{font-weight:500;font-size:11px;overflow-wrap:anywhere}.tidal-scope .sidebar-demo-project small{font-size:11px;color:var(--t-muted)}.tidal-scope .sidebar-demo-project-meter{display:flex;flex-direction:column;gap:5px;text-align:end;flex:none;width:52px;font-size:11px;font-variant-numeric:tabular-nums;color:var(--t-muted)}.tidal-scope .sidebar-demo-project-meter>i{height:3px;background:var(--t-wash);border-radius:3px;overflow:hidden}.tidal-scope .sidebar-demo-project-meter>i>i{display:block;height:100%;border-radius:inherit;background:var(--t-ink);transform-origin:left}.tidal-scope .sidebar-demo-note{font-size:11px;line-height:1.6;color:var(--t-muted);margin:20px 0 0}.tidal-scope .sidebar-demo-activity{list-style:none;margin:0;padding:0}.tidal-scope .sidebar-demo-activity>li{display:flex;gap:12px;padding:15px 0;border-top:1px solid var(--t-border);align-items:start}.tidal-scope .sidebar-demo-activity>li>span{font-size:11px;color:var(--t-muted)}.tidal-scope .sidebar-demo-activity p{margin:0;font-size:11px;overflow-wrap:anywhere}.tidal-scope .sidebar-demo-activity small{display:block;margin-top:4px;font-size:11px;color:var(--t-muted)}.tidal-scope .sidebar-demo-settings p{display:flex;justify-content:space-between;flex-wrap:wrap;gap:8px;padding:14px 0;margin:0;border-bottom:1px solid var(--t-border);font-size:11px}.tidal-scope .sidebar-demo-settings strong{font-weight:500}.tidal-scope .sidebar-demo-settings span{color:var(--t-muted)}.tidal-scope .sidebar-demo-profile{padding:20px 0}.tidal-scope .sidebar-demo-profile img{width:64px;height:64px;border-radius:16px}.tidal-scope .sidebar-demo-profile h4{font-size:18px;font-weight:500;margin:12px 0 4px}.tidal-scope .sidebar-demo-profile p{font-size:11px;color:var(--t-muted);margin:0}\n@keyframes sidebar-demo-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}@keyframes sidebar-demo-bar{from{transform:scaleX(0)}to{transform:scaleX(1)}}@media(prefers-reduced-motion:no-preference){.tidal-scope .sidebar-demo-title{animation:sidebar-demo-in 380ms var(--t-ease-out) both}.tidal-scope .sidebar-demo-summary{animation:sidebar-demo-in 420ms var(--t-ease-out) 50ms both}.tidal-scope .sidebar-demo-project{animation:sidebar-demo-in 420ms var(--t-ease-out) both}.tidal-scope .sidebar-demo-project:nth-child(2){animation-delay:90ms}.tidal-scope .sidebar-demo-project:nth-child(3){animation-delay:145ms}.tidal-scope .sidebar-demo-project:nth-child(4){animation-delay:200ms}.tidal-scope .sidebar-demo-project-meter>i>i{animation:sidebar-demo-bar 650ms var(--t-ease-out) 180ms both}}";

const views = [{label:"Overview",icon:LayoutGrid},{label:"Projects",icon:Folder},{label:"Activity",icon:Activity},{label:"Settings",icon:Settings2}];

const projects = [{name:"Website",detail:"Design review",progress:72},{name:"Mobile app",detail:"In development",progress:48},{name:"Brand assets",detail:"Ready to share",progress:100}];

export function SidebarDemo(){
  const [view,setView]=useState("Overview");
  return <div className="sidebar-specimen"><TidalSidebar title="Northstar" mark={<Layers size={17}/>} navigation={<><TidalSidebarGroup label="Workspace">{views.slice(0,3).map(({label,icon:Icon})=><TidalSidebarAction key={label} label={label} icon={<Icon size={17}/>} badge={label==="Projects"?3:undefined} active={view===label} onClick={()=>setView(label)}/>)}</TidalSidebarGroup><TidalSidebarGroup label="Manage"><TidalSidebarAction label="Settings" icon={<Settings2 size={17}/>} active={view==="Settings"} onClick={()=>setView("Settings")}/><TidalSidebarAction label="Billing" icon={<ArrowUpRight size={17}/>} disabled/></TidalSidebarGroup></>} footer={<TidalSidebarAction label="Ava Chen" icon={<img src={tidalExampleAvatarDataUri("01")} alt=""/>} active={view==="Profile"} onClick={()=>setView("Profile")}/> }>
    <header className="sidebar-demo-header"><span>Workspace</span><span>Local sample</span></header><section className="sidebar-demo-body" key={view}><div className="sidebar-demo-title"><div><p>WORKSPACE</p><h3>{view}</h3></div><span className="sidebar-demo-view-icon" aria-hidden="true"><ArrowDownLeft size={20}/></span></div>
    {view==="Overview"||view==="Projects"?<><div className="sidebar-demo-summary"><span><strong>3</strong>Active projects</span><span><strong>1</strong>Ready for review</span></div><div className="sidebar-demo-projects"><header><span>Projects</span><span>Progress</span></header>{projects.map(p=><div className="sidebar-demo-project" key={p.name}><span className="sidebar-demo-project-icon" aria-hidden="true"><Folder size={16}/></span><span><strong>{p.name}</strong><small>{p.detail}</small></span><span className="sidebar-demo-project-meter"><span>{p.progress}%</span><i aria-hidden="true"><i style={{width:`${p.progress}%`}}/></i></span></div>)}</div></>:view==="Activity"?<ol className="sidebar-demo-activity">{["Brand assets marked ready","Website moved to design review","Mobile app updated"].map((s,i)=><li key={s}><span aria-hidden="true">0{i+1}</span><p>{s}<small>Sample activity</small></p></li>)}</ol>:view==="Settings"?<div className="sidebar-demo-settings"><p><span>Workspace name</span><strong>Northstar</strong></p><p><span>Default access</span><strong>Private</strong></p><p><span>Members</span><strong>3</strong></p></div>:<div className="sidebar-demo-profile"><img src={tidalExampleAvatarDataUri("01")} alt="Fictional Ava Chen"/><h4>Ava Chen</h4><p>Workspace owner</p></div>}
    <p className="sidebar-demo-note">Explore the sample workspace navigation.</p></section>
  </TidalSidebar></div>;
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <SidebarDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

TidalSidebar wraps navigation, optional footer and page children. Required title and navigation; optional mark, navigationLabel(defaultWorkspace), controlled collapsed/onCollapsedChange or defaultCollapsed. Root forwards native div attributes/ref. ResizeObserver measures its own container: at560px or wider it shows an expanded218px or collapsed66px rail; below560px it becomes an in-flow nonmodal disclosure. Mobile menu never overlays the page or traps focus; native toggle announces expansion, Escape closes from within the component and returns navigation-owned focus, selection closes and returns focus when it owns focus. Compact navigation is bounded240px with internal scrolling. Resizing transfers focus away from controls being hidden. Collapsed desktop state persists independently of mobile open state. No global shortcut, storage, URL routing, requests or sample workspace is introduced by source. TidalSidebarGroup requires label and forwards div/ref/attributes. TidalSidebarLink forwards native anchor attributes/ref/events, requires label, supports decorative icon, visual-only badge and active(aria-current=page). Supply your own accessible label if a badge carries essential meaning. Normal unmodified same-tab links close mobile navigation; modifier clicks, targets, download and prevented events preserve native behavior. TidalSidebarAction forwards button/ref/events/type(defaultbutton)/disabled, supports the same label/icon/badge/active(aria-pressed when active) and closeOnSelect(defaulttrue). Caller-prevented click skips closing. Consumer owns destination, selected page, submissions and any main-content focus policy. Icons must remain decorative; the literal label stays accessible in collapsed mode. Footer content is consumer-owned and should use the supplied items for collapse behavior. Original neutral surfaces, selected edge, icon feedback, width transition and finite coordinated group entrances; full labels wrap,44px controls, scoped light/dark tokens and reduced motion. Container sizing needs ResizeObserver (modern browsers); initial server render is compact for safe hydration.
