---
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/"
---

# Workspace switcher

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

Pro. Its export: `WorkspaceSwitcher`.

## Try it

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 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.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-workspace-switcher.json --yes
```

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

## Usage

```tsx
import { useState } from 'react';
import {
  WorkspaceSwitcher,
  WorkspaceSwitcherAction,
  WorkspaceSwitcherContent,
  WorkspaceSwitcherItem,
  WorkspaceSwitcherLabel,
  WorkspaceSwitcherTrigger,
} from '@/components/ui/goop/workspace-switcher';

const WORKSPACES = [
  { id: 'fieldwork', name: 'Fieldwork', detail: '9 members' },
  { id: 'home', name: 'Home', detail: '1 member' },
  { id: 'reading-group', name: 'Reading group', detail: '4 members' },
];

function Workspaces({ onCreate }: { onCreate: () => void }) {
  const [current, setCurrent] = useState('fieldwork');
  const now = WORKSPACES.find((one) => one.id === current) ?? WORKSPACES[0];
  return (
    <WorkspaceSwitcher value={current} onValueChange={setCurrent}>
      <WorkspaceSwitcherTrigger name={now.name} tileOnly />
      <WorkspaceSwitcherContent>
        <WorkspaceSwitcherLabel>Switch workspace</WorkspaceSwitcherLabel>
        {WORKSPACES.map((one) => (
          <WorkspaceSwitcherItem key={one.id} value={one.id} name={one.name} detail={one.detail} />
        ))}
        <WorkspaceSwitcherAction onSelect={onCreate} />
      </WorkspaceSwitcherContent>
    </WorkspaceSwitcher>
  );
}
```

- Fits: frame: switcher.
- Also known as: TeamSwitcher, OrgSwitcher, WorkspaceMenu, TenantPicker.
- Never hand-wire a MenuButton and a DropdownMenu for it.
- height, width, padding, corner, border, background, text: add no class for these.

## API reference

### Parts

- `WorkspaceSwitcherTrigger` — The button that opens the switcher, the theme's MenuButton `shape="rounded"`; its props: workspace-switcher--trigger.md
- `WorkspaceSwitcherContent` — The menu the trigger opens (`role="menu"`, named "Workspaces"); its props: workspace-switcher--content.md
- `WorkspaceSwitcherLabel` — The heading over the workspaces, "Workspaces" when given no words
- `WorkspaceSwitcherItem` — One workspace (`role="menuitemradio"`); its props: workspace-switcher--item.md
- `WorkspaceSwitcherAction` — The menu's last row, under a line of its own; icon?: IconName | null = 'plus'; also takes onSelect?: (event: Event) => void; disabled?: boolean; asChild?: boolean

- data-slot values (to select a part by): workspace-switcher-empty, workspace-switcher-header, workspace-switcher-item, workspace-switcher-item-description, workspace-switcher-item-label, workspace-switcher-item-shortcut, workspace-switcher-item-text, workspace-switcher-label, workspace-switcher-status, workspace-switcher-status-icon, workspace-switcher-trigger

### 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 that narrows the workspaces as you type (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 (default "Find a workspace…").
- searchLabel?: string = 'Find a workspace' — The search field's name for a screen reader (default "Find a workspace").
- empty?: ReactNode = 'No workspace matches' — The line shown while no workspace matches the search (default "No workspace matches").
- defaultSearch?: string = '' — The words the search field holds as the menu opens (empty when left out).
- 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, winning over a `hue`; its initials stay light.
- hue?: 'blue' | 'green' | 'orange' | 'pink' | 'red' | 'yellow' | 'neutral' — One of the six hue words (or `neutral`, the grey) instead of a `fill`, readable in light and dark; left out (and no `fill`), Meadow's pink.
- initials?: string — One or two letters in the tile; left out, the name's first letters (one on the small tiles).
- 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 grey line under the name: its members ("4 members"), its plan or the person's role there.
- shortcut?: string — The row's chord (`mod+1`; `mod` is ⌘ on an Apple keyboard, Ctrl elsewhere): drawn at the row's end in the page's own keys, it switches to this workspace while the menu is open, or from anywhere with the switcher's `shortcuts="page"`.
- Also takes: disabled?: boolean

### 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 (`switching`, `failed` or `idle`), in place of the promise's.
- shortcuts?: 'menu' | 'page' | 'off' = 'menu' — Whether a row's drawn `shortcut` switches to it: `menu` (the default) while the menu is open, `page` from anywhere on the page too, `off` never (your own code listens).
- 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; default "Could not switch to <name>".
- 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 (the menu's own default, `true`).
- children?: ReactNode — A `WorkspaceSwitcherTrigger`, then a `WorkspaceSwitcherContent`.
- State: value (value / defaultValue / onValueChange); open (open / defaultOpen / onOpenChange); drawn by data-focus-visible, data-disabled

### WorkspaceSwitcherTrigger

The button that opens the switcher, the theme's MenuButton `shape="rounded"`.

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

### Options

- fill?: string — The workspace's own colour, any CSS colour, winning over a `hue`; its initials stay light.
- hue?: 'blue' | 'green' | 'orange' | 'pink' | 'red' | 'yellow' | 'neutral' — One of the six hue words (or `neutral`, the grey) instead of a `fill`, readable in light and dark; left out (and no `fill`), Meadow's pink.
- initials?: string — One or two letters in the tile; left out, the name's first letters (one on the small tiles).
- 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
- Also takes: type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean

## Keyboard

- Enter: on the trigger: open, the first row active
- Space: on the trigger: open, the first row active
- ArrowDown: on the trigger: open, the first row active
- ArrowUp: on the trigger: open, the last row active
- ArrowDown / ArrowUp: move the active row, looping past either end
- Home / End: first or last row
- Enter: pick the active row (a workspace becomes current) and close
- Escape: close, the focus back on the trigger
- Tab: close

## Accessibility

- The behaviour layer under the part answers keys, focus and dismissal: never write your own.
- focus-visible: the attribute data-focus-visible
- disabled: the attribute data-disabled

## 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.

## Related

- [Account menu](/themes/meadow/components/account-menu): The signed-in person's menu.
- [Notification center](/themes/meadow/components/notification-center): A bell button with an unread count that opens a panel of notifications.
- [Toast](/themes/meadow/components/toast): A short notice at a corner of the app that confirms an action and goes by itself, with an optional action such as Undo.
- [Command palette](/themes/meadow/components/command-palette): A window of commands under a search field, opened over the app by a key chord such as Cmd K, to run an action by typing its name.
