Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-workspace-switcher.json --yes

Workspace switcher

Pro

The sidebar's menu that shows the current workspace and switches to another or creates one, for React and Tailwind CSS. Part of Goop Pro.

Open the switcher: type in its search field to narrow nine workspaces and press Enter, or press a row’s ⌘1–⌘9. The summary says while the switcher is open; the spinner shows while it switches; Closed Archive refuses, the pick is undone and the red mark says why. Look shows it under the pages’ own workspace button, with a long name, across a phone drawer, or as the tile alone. The workspaces, the wait and the refusal are our own sample: nothing is switched.

When to use

  • The sidebar's menu that shows the current workspace and switches to another or creates one.
  • Also called: team switcher or org switcher.

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 Workspace switcher on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

Terminal
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-workspace-switcher.json --yes
PROMPT
Add the Goop Workspace switcher to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import {
  WorkspaceSwitcher, WorkspaceSwitcherTrigger, WorkspaceSwitcherContent, WorkspaceSwitcherLabel, WorkspaceSwitcherItem, WorkspaceSwitcherAction,
} from '@/components/ui/goop/workspace-switcher';
import { useState } from 'react';
import { Sidebar, SidebarHeader, SidebarHeaderRow } from '@/components/ui/goop/sidebar';
import { DropdownMenuItem } from '@/components/ui/goop/dropdown-menu';

function Navigation({ onCreate, switchTo }: { onCreate: () => void; switchTo: (id: string) => Promise<void> }) {
  const workspaces = [
    { id: 'fieldwork', name: 'Fieldwork', initials: 'F', hue: 'blue' },
    { id: 'reading-group', name: 'Reading group', initials: 'RG', hue: 'green' },
    { id: 'diallo-dental', name: 'Diallo Dental', initials: 'DD', hue: 'orange' },
  ] as const;
  const [current, setCurrent] = useState('fieldwork');
  const now = workspaces.find((workspace) => workspace.id === current) ?? workspaces[0];
  return (
    <Sidebar aria-label="Main">
      <SidebarHeader>
        <SidebarHeaderRow>
          <WorkspaceSwitcher value={current} onValueChange={(id) => switchTo(id).then(() => setCurrent(id))}>
            <WorkspaceSwitcherTrigger name={now.name} initials={now.initials} hue={now.hue} />
            <WorkspaceSwitcherContent>
              <WorkspaceSwitcherLabel />
              {workspaces.map((workspace, at) => (
                <WorkspaceSwitcherItem
                  key={workspace.id}
                  value={workspace.id}
                  name={workspace.name}
                  initials={workspace.initials}
                  hue={workspace.hue}
                  shortcut={`mod+${at + 1}`}
                />
              ))}
              <DropdownMenuItem icon="settings">Workspace settings</DropdownMenuItem>
              <WorkspaceSwitcherAction onSelect={onCreate} />
            </WorkspaceSwitcherContent>
          </WorkspaceSwitcher>
        </SidebarHeaderRow>
      </SidebarHeader>
    </Sidebar>
  );
}
  • Fits: frame (its recipe); frame: switcher.
  • Also known as: TeamSwitcher, OrgSwitcher, WorkspaceMenu, TenantPicker.
  • Put one WorkspaceSwitcher at the start of the sidebar's header row (SidebarHeaderRow) with the current workspace as its value, its IconButtons (search, new) after it; list every workspace as a WorkspaceSwitcherItem and end with a WorkspaceSwitcherAction ("Create workspace"). Never hand-wire a MenuButton and a DropdownMenu for it.
  • height, width, padding, gap, corner, border, background, text: add no class for these.

API reference

  • Each option with its sentence: workspace-switcher--options.md
  • State: value (value / defaultValue / onValueChange); open (open / defaultOpen / onOpenChange)
Parts
PartWhat it is
WorkspaceSwitcherTriggerThe button that opens the switcher; its props: workspace-switcher--trigger.md
WorkspaceSwitcherContentThe menu the trigger opens (role="menu", named "Workspaces"); its props: workspace-switcher--content.md
WorkspaceSwitcherLabelThe heading over the workspaces, "Workspaces" when given no words
WorkspaceSwitcherItemOne workspace (role="menuitemradio"); its props: workspace-switcher--item.md
WorkspaceSwitcherActionThe menu's last row, under a line of its own; its props: workspace-switcher--action.md

WorkspaceSwitcherAction

The menu's last row, under a line of its own.

TSX
import { WorkspaceSwitcherAction } from '@/components/ui/goop/workspace-switcher';

Options

  • icon?: IconName = 'plus' — The pack icon before the words: the plus when left out.
  • Also takes: onSelect?: (event: Event) => void; disabled?: boolean; asChild?: boolean; variant?: 'default' | 'destructive' = 'default'

WorkspaceSwitcherContent

The menu the trigger opens (role="menu", named "Workspaces").

TSX
import { WorkspaceSwitcherContent } from '@/components/ui/goop/workspace-switcher';

Options

  • search?: boolean — A search field over the rows, by name and detail; the menu opens with the focus in it.
  • searchPlaceholder?: string = 'Find a workspace…' — The search field's grey words while it is empty.
  • searchLabel?: string = 'Find a workspace' — The search field's name for a screen reader.
  • empty?: ReactNode = 'No workspace matches' — The line shown while no workspace matches the search.
  • defaultSearch?: string = '' — The words the search field holds as the menu opens.
  • Also takes: container?: HTMLElement | null

WorkspaceSwitcherItem

One workspace (role="menuitemradio").

TSX
import { WorkspaceSwitcherItem } from '@/components/ui/goop/workspace-switcher';

Options

  • fill?: string — The workspace's own colour, any CSS colour (with no hue either, a hue from its name); its initials stay white.
  • hue?: AvatarHue — One of the theme's six hues (or neutral) instead of a fill.
  • initials?: string — One or two letters in the tile; left out, the name's first letters ("Diallo Dental" → "DD").
  • image?: string — The address of the workspace's picture, drawn over its initials once it has loaded.
  • value: string — The workspace's id: the switcher's value while it is the current one.
  • name: string — The workspace's name.
  • detail?: ReactNode — A word after the name in the grey: its plan or the person's role there.
  • shortcut?: string — The row's chord (mod+1; ⌘ on an Apple keyboard, Ctrl elsewhere), drawn at the row's end: it switches to this workspace while the menu is open, or anywhere with shortcuts="page".
  • Also takes: disabled?: boolean
  • Types: AvatarHue = Exclude<Hue, 'primary'>

WorkspaceSwitcher: every option

TSX
import { WorkspaceSwitcher } from '@/components/ui/goop/workspace-switcher';

Options

  • value?: string — The current workspace's id, held by the caller (with onValueChange).
  • defaultValue?: string — The current workspace's id when the switcher holds it itself.
  • onValueChange?: (value: string) => unknown — Called with the id of the workspace picked; the menu then closes.
  • status?: 'idle' | 'switching' | 'failed' — The switch's status held by the caller, in place of the promise's.
  • shortcuts?: 'menu' | 'page' | 'off' = 'menu' — Whether a row's shortcut switches to it: menu while the menu is open, page anywhere too, off never.
  • switchingMessage?: (name: string) => string — What a screen reader hears as a switch starts; default "Switching to <name>".
  • failedMessage?: (name: string) => string — What a screen reader hears, and the trigger's title says, when a switch is refused.
  • open?: boolean — The menu open, held by the caller (with onOpenChange).
  • defaultOpen?: boolean — Open when it first draws.
  • onOpenChange?: (open: boolean) => void — Called as the menu opens and closes.
  • modal?: boolean — Whether the rest of the page is shut off while the menu is open (true by default).
  • children?: ReactNode — A WorkspaceSwitcherTrigger, then a WorkspaceSwitcherContent.
  • State: value (value / defaultValue / onValueChange); open (open / defaultOpen / onOpenChange)

WorkspaceSwitcherTrigger

The button that opens the switcher.

TSX
import { WorkspaceSwitcherTrigger } from '@/components/ui/goop/workspace-switcher';

Options

  • fill?: string — The workspace's own colour, any CSS colour (with no hue either, a hue from its name); its initials stay white.
  • hue?: AvatarHue — One of the theme's six hues (or neutral) instead of a fill.
  • initials?: string — One or two letters in the tile; left out, the name's first letters ("Diallo Dental" → "DD").
  • image?: string — The address of the workspace's picture, drawn over its initials once it has loaded.
  • name: string — The current workspace's name, beside its tile: the button's name.
  • tileOnly?: boolean = false — The tile alone with the chevron, the name kept for a screen reader: a collapsed rail.
  • Also takes: type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean
  • Types: AvatarHue = Exclude<Hue, 'primary'>

Keyboard

KeyWhat it does
Enter SpaceOpen the menu on its first row; on a row, pick it and close
ArrowDownOpen the menu on its first row; move to the next row, looping
ArrowUpOpen the menu on its last row; move to the row before, looping

Accessibility

  • The part itself answers the keys above.

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.

goop.so/themes/trail/components/workspace-switcher.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-workspace-switcher.json --yes

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.