---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Sidebar

The app's main navigation down one side of the window, for React and Tailwind CSS. Free, MIT.

Free. Its export: `Sidebar`.

## Try it: sidebar

Press a row (or Tab to it and press Enter) to switch the page beside it; read the inbox’s notices and its count goes down; switch the workspace from the menu at the top; collapse the sidebar to its rail of icons with the toggle or ⌘B / Ctrl+B and hover a row for its name; on a phone-sized window open it from the top bar’s button. In a theme whose frame is the icon rail (Meadow), the sidebar is that rail beside a panel of the day’s notes: the rail’s icons switch the section, its plus adds a note, and the same toggle and keys collapse it to the rail alone.

The pages, the notes, the workspaces and the person are our own sample, and signing out does nothing.

## Try it: sidebar-settings

Press a row to switch the settings page beside it; type in the field to filter the rows (“mem”, “bill”); “Back to app” leaves settings, and a button brings you back.

The pages are our own sample with a line each. The filter is this example’s: the settings sidebar’s field filters nothing by itself.

## When to use

- The app's main navigation down one side of the window.
- Also called: side navigation or nav drawer.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Sidebar on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

```sh
npx shadcn@4.23.1 add @goop/trail-sidebar
```

```text
Add the Goop Sidebar to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import {
  SidebarProvider, SidebarScope, useSidebar, Sidebar, SidebarHeader, SidebarHeaderRow, SidebarTitle, SidebarContent, SidebarFooter, SidebarRailToggle,
} from '@/components/ui/goop/sidebar';
import { WorkspaceSwitcher, WorkspaceSwitcherTrigger, WorkspaceSwitcherContent, WorkspaceSwitcherItem } from '@/components/ui/goop/workspace-switcher';
import { SidebarGroup, SidebarGroupContent, SidebarMenu, SidebarMenuItem } from '@/components/ui/goop/sidebar-group';
import { SidebarMenuButton, SidebarMenuBadge } from '@/components/ui/goop/sidebar-menu-button';
import { AccountMenu, AccountMenuTrigger, AccountMenuContent, AccountMenuSignOut } from '@/components/ui/goop/account-menu';

<Sidebar aria-label="Main" storageKey="sidebar:collapsed">
  <SidebarHeader>
    <SidebarHeaderRow>
      <WorkspaceSwitcher defaultValue="fieldwork">
        <WorkspaceSwitcherTrigger name="Fieldwork" />
        <WorkspaceSwitcherContent>
          <WorkspaceSwitcherItem value="fieldwork" name="Fieldwork" />
        </WorkspaceSwitcherContent>
      </WorkspaceSwitcher>
      <SidebarRailToggle />
    </SidebarHeaderRow>
  </SidebarHeader>
  <SidebarContent>
    <SidebarGroup>
      <SidebarGroupContent>
        <SidebarMenu>
          <SidebarMenuItem>
            <SidebarMenuButton href="/inbox" icon="inbox" size="sm" isActive>
              Inbox
              <SidebarMenuBadge>3</SidebarMenuBadge>
            </SidebarMenuButton>
          </SidebarMenuItem>
        </SidebarMenu>
      </SidebarGroupContent>
    </SidebarGroup>
  </SidebarContent>
  <SidebarFooter>
    <AccountMenu>
      <AccountMenuTrigger name="Teodora Valk" email="teodora@fieldwork.test" />
      <AccountMenuContent>
        <AccountMenuSignOut />
      </AccountMenuContent>
    </AccountMenu>
  </SidebarFooter>
</Sidebar>
```

- Fits: frame (its recipe).
- height, width, padding, gap, background, text, motion: add no class for these.

## API reference

### Options

- `variant: default | settings = default`
- `open?: boolean` — The wide column (`true`) or the rail (`false`), when the caller holds it.
- `defaultOpen?: boolean = true` — Whether it starts as the wide column or the rail, when the sidebar holds it.
- `onOpenChange?: (open: boolean) => void` — Called as it opens (`true`) or collapses to the rail (`false`).
- `shortcut?: string | false = 'mod+b'` — The key that switches it (`mod` is ⌘ on an Apple keyboard, Ctrl elsewhere); `false` for none.
- `storageKey?: string` — Remembers the rail across a reload under this local-storage key (one per sidebar).
- `container?: HTMLElement | null` — Where the rail's tooltips are drawn; the end of `<body>` when left out.

- State: open (open / defaultOpen / onOpenChange)

### Parts

- `SidebarProvider` — Holds the sidebar's rail state for what is outside the `nav`
- `SidebarScope` — Where the sidebar's parts stand outside the sidebar, beside it (a settings page's section navigation of `SidebarGroup` rows)
- `SidebarHeader` — The region at the top, which never scrolls
- `SidebarHeaderRow` — The header's row of controls
- `SidebarTitle` — The app's name in the header row (`<SidebarTitle>Issue tracker</SidebarTitle>` before the `SidebarRailToggle`)
- `SidebarContent` — The column of groups (the theme's `SidebarGroup`s), which scrolls under the header; its end is its own
- `SidebarFooter` — The region at the foot, which never scrolls
- `SidebarRailToggle` — The rail toggle — the theme's quiet 28 px round IconButton with the pack's sidebar mark, named for what a press does ("Collapse sidebar", "Expand sidebar"), saying the sidebar it controls, whether it is expanded and its key; its props: sidebar--rail-toggle.md
- `useSidebar` — The sidebar's rail state, for a part of the caller's own inside it (`const { open } = useSidebar()`)

- Class recipes (cva): sidebarVariants (Sidebar)
- data-slot values (to select a part by): sidebar, sidebar-content, sidebar-content-end, sidebar-content-inner, sidebar-footer, sidebar-header, sidebar-header-row, sidebar-rail-toggle, sidebar-title

### SidebarRailToggle

The rail toggle — the theme's quiet 28 px round IconButton with the pack's sidebar mark, named for what a press does ("Collapse sidebar", "Expand sidebar"), saying the sidebar it controls, whether it is expanded and its key.

```tsx
import { SidebarRailToggle } from '@/components/ui/goop/sidebar';
```

### Options

- aria-label?: string — One spoken name in both states, instead of the two below.
- collapseLabel?: string = 'Collapse sidebar' — Its spoken name while the sidebar is expanded.
- expandLabel?: string = 'Expand sidebar' — Its spoken name while the sidebar is the rail.
- children?: ReactElement — With `asChild`, that one control.
- Also takes: asChild?: boolean; type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading'

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

Follows shadcn/ui's file names and conventions.

## Related

- [Workspace switcher](/themes/trail/components/workspace-switcher): The sidebar's menu that shows the current workspace and switches to another or creates one.
- [Sidebar group](/themes/trail/components/sidebar-group): A titled group of links in the sidebar, such as a team's pages or your projects, that can fold open and closed.
- [Sidebar menu button](/themes/trail/components/sidebar-menu-button): One row of the sidebar, its icon and words, that opens a page or runs an action and shows which page is current.
- [Account menu](/themes/trail/components/account-menu): The signed-in person's menu: who is signed in, the light and dark choice, and signing out.
