# Workspace switcher

Search and switch among consumer-owned workspaces with exact roles, statuses, form values, and native create or manage destinations.

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

## When to use

- Use it when a page needs search and switch among consumer-owned workspaces with exact roles, statuses, form values, and native create or manage destinations.
- 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 workspace switcher.

## 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 Workspace switcher

```sh
npx shadcn@latest add @tidal-pro/workspace-switcher
```

Stylesheets: `components/ui/tidal.css`, `components/ui/workspace-switcher.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/workspace-switcher.css";
import{TidalWorkspaceSwitcher}from"./components/ui/workspace-switcher";
export default(p:Parameters<typeof TidalWorkspaceSwitcher>[0])=><div className="tidal-scope"><TidalWorkspaceSwitcher {...p}/></div>;
```

## Structured props

- `TidalWorkspaceSwitcher.activeWorkspaceId: string | null`: Required active workspace id value accepted by this exported component.
- `TidalWorkspaceSwitcher.label: ReactNode`: Required label value accepted by this exported component.
- `TidalWorkspaceSwitcher.onHighlightedWorkspaceChange: (workspaceId: string | undefined, event: TidalComboboxActiveEvent) => void`: Callback invoked when the highlighted workspace change interaction is proposed.
- `TidalWorkspaceSwitcher.onOpenChange: (open: boolean, event: TidalComboboxOpenEvent) => void`: Callback invoked when the open change interaction is proposed.
- `TidalWorkspaceSwitcher.onQueryChange: (value: string, event: ChangeEvent<HTMLInputElement>) => void`: Callback invoked when the query change interaction is proposed.
- `TidalWorkspaceSwitcher.onWorkspaceChange: (workspace: TidalWorkspaceOption, event: TidalComboboxSelectionEvent) => void`: Callback invoked when the workspace change interaction is proposed.
- `TidalWorkspaceSwitcher.open: boolean`: Required open value accepted by this exported component.
- `TidalWorkspaceSwitcher.query: string`: Required query value accepted by this exported component.
- `TidalWorkspaceSwitcher.workspaces: ReadonlyArray<TidalWorkspaceOption>`: Required workspaces value accepted by this exported component.
- `TidalWorkspaceSwitcher.createDisabled?: boolean | undefined` (default false): Optional create disabled value accepted by this exported component.
- `TidalWorkspaceSwitcher.createHref?: string | undefined`: Optional create href value accepted by this exported component.
- `TidalWorkspaceSwitcher.createLabel?: ReactNode`: Optional create label value accepted by this exported component.
- `TidalWorkspaceSwitcher.createLinkProps?: DestinationProps | undefined`: Optional create link props value accepted by this exported component.
- `TidalWorkspaceSwitcher.createLinkRef?: Ref<HTMLAnchorElement> | undefined`: Optional create link ref value accepted by this exported component.
- `TidalWorkspaceSwitcher.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalWorkspaceSwitcher.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalWorkspaceSwitcher.emptyMessage?: ReactNode` (default "No workspaces match this search."): Optional empty message value accepted by this exported component.
- `TidalWorkspaceSwitcher.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalWorkspaceSwitcher.form?: string | undefined`: Optional form value accepted by this exported component.
- `TidalWorkspaceSwitcher.hiddenInputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, "disabled" | "form" | "name" | "type" | "value" | "defaultValue" | "children" | "dangerouslySetInnerHTML" | "readOnly"> | undefined`: Optional hidden input props value accepted by this exported component.
- `TidalWorkspaceSwitcher.hiddenInputRef?: Ref<HTMLInputElement> | undefined`: Optional hidden input ref value accepted by this exported component.
- `TidalWorkspaceSwitcher.highlightedWorkspaceId?: string | undefined`: Optional highlighted workspace id value accepted by this exported component.
- `TidalWorkspaceSwitcher.hint?: ReactNode`: Optional hint value accepted by this exported component.
- `TidalWorkspaceSwitcher.inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, "disabled" | "type" | "value" | "defaultValue" | "role" | "aria-activedescendant" | "aria-autocomplete" | "aria-controls" | "aria-disabled" | "aria-expanded" | "aria-readonly" | "children" | "dangerouslySetInnerHTML" | "placeholder" | "readOnly"> | undefined`: Optional input props value accepted by this exported component.
- `TidalWorkspaceSwitcher.inputRef?: Ref<HTMLInputElement> | undefined`: Optional input ref value accepted by this exported component.
- `TidalWorkspaceSwitcher.labels?: Partial<{ listbox: string; open: string; close: string; selected: ReactNode; noSelection: ReactNode; readOnly: ReactNode; searchPlaceholder: string; invalid: ReactNode; outsideResults: ReactNode; }> | undefined`: Optional labels value accepted by this exported component.
- `TidalWorkspaceSwitcher.manageDisabled?: boolean | undefined` (default false): Optional manage disabled value accepted by this exported component.
- `TidalWorkspaceSwitcher.manageHref?: string | undefined`: Optional manage href value accepted by this exported component.
- `TidalWorkspaceSwitcher.manageLabel?: ReactNode`: Optional manage label value accepted by this exported component.
- `TidalWorkspaceSwitcher.manageLinkProps?: DestinationProps | undefined`: Optional manage link props value accepted by this exported component.
- `TidalWorkspaceSwitcher.manageLinkRef?: Ref<HTMLAnchorElement> | undefined`: Optional manage link ref value accepted by this exported component.
- `TidalWorkspaceSwitcher.name?: string | undefined`: Optional name value accepted by this exported component.
- `TidalWorkspaceSwitcher.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalWorkspaceSwitcher.toggleButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "type" | "aria-controls" | "aria-disabled" | "aria-expanded" | "aria-label" | "children" | "dangerouslySetInnerHTML"> | undefined`: Optional toggle button props value accepted by this exported component.
- `TidalWorkspaceSwitcher.toggleButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional toggle button ref value accepted by this exported component.

## Complete usage example

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

```tsx
"use client";

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

import { useId, useState, type MouseEvent } from "react";

import { TidalWorkspaceSwitcher, type TidalWorkspaceOption } from "./components/ui/workspace-switcher";

import "./components/ui/workspace-switcher.css";

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



const tidalExampleStyles = ".workspace-switcher-demo {\n  width: 100%;\n  max-width: 660px;\n  min-width: 0;\n  display: grid;\n  gap: 14px;\n  padding: 18px;\n}\n\n.workspace-switcher-demo > .tidal-workspace-switcher {\n  width: 100%;\n}\n\n.workspace-switcher-demo-actions {\n  display: grid;\n  grid-template-columns: repeat(2, minmax(0, 1fr));\n  gap: 8px;\n}\n\n.workspace-switcher-demo-actions button {\n  min-width: 44px;\n  min-height: 44px;\n  padding: 9px 12px;\n  border: 1px solid var(--t-ink);\n  border-radius: 10px;\n  color: var(--t-surface);\n  background: var(--t-ink);\n  font: inherit;\n  font-size: 12px;\n  font-weight: 600;\n  cursor: pointer;\n  transition:\n    color 160ms var(--t-ease-out),\n    background 160ms var(--t-ease-out),\n    transform 140ms var(--t-ease-out);\n}\n\n.workspace-switcher-demo-actions button + button {\n  color: var(--t-ink);\n  background: var(--t-surface);\n  border-color: var(--t-border);\n}\n\n.workspace-switcher-demo-actions button:hover {\n  transform: translateY(-1px);\n}\n\n.workspace-switcher-demo-actions button:active {\n  transform: scale(0.985);\n}\n\n.workspace-switcher-demo-actions button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 2px;\n}\n\n.workspace-switcher-demo-destination {\n  min-width: 0;\n  padding: 14px;\n  border: 1px solid var(--t-border);\n  border-radius: 12px;\n  background: var(--t-subtle);\n}\n\n.workspace-switcher-demo-destination[hidden] {\n  display: none;\n}\n\n.workspace-switcher-demo-destination h3,\n.workspace-switcher-demo-destination p,\n.workspace-switcher-demo > [role=\"status\"],\n.workspace-switcher-demo-note {\n  margin: 0;\n  overflow-wrap: anywhere;\n}\n\n.workspace-switcher-demo-destination h3 {\n  font-size: 13px;\n  line-height: 1.3;\n}\n\n.workspace-switcher-demo-destination p,\n.workspace-switcher-demo > [role=\"status\"],\n.workspace-switcher-demo-note {\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n}\n\n.workspace-switcher-demo-destination p {\n  margin-top: 4px;\n}\n\n.workspace-switcher-demo-note {\n  padding-top: 12px;\n  border-top: 1px solid var(--t-border);\n}\n\n@container preview-canvas (max-width: 390px) {\n  .workspace-switcher-demo {\n    padding: 10px;\n  }\n\n  .workspace-switcher-demo-actions {\n    grid-template-columns: minmax(0, 1fr);\n  }\n}\n\n@media (max-width: 480px) {\n  .workspace-switcher-demo {\n    padding: 10px;\n  }\n\n  .workspace-switcher-demo-actions {\n    grid-template-columns: minmax(0, 1fr);\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .workspace-switcher-demo-actions button {\n    transition: none;\n  }\n\n  .workspace-switcher-demo-actions button:hover,\n  .workspace-switcher-demo-actions button:active {\n    transform: none;\n  }\n}";

const WORKSPACES: readonly TidalWorkspaceOption[] = [
  {
    id: "north-star",
    name: "North Star",
    role: "Owner",
    status: "Active",
    description: "Product planning and launch work",
    searchTerms: ["product", "launch"],
  },
  {
    id: "field-notes",
    name: "Field Notes",
    role: "Editor",
    status: "Active",
    description: "Research briefs and customer notes",
    searchTerms: ["research", "customer"],
  },
  {
    id: "studio-lab",
    name: "Studio Lab",
    role: "Viewer",
    status: "Review",
    description: "Design experiments awaiting review",
    searchTerms: ["design", "review"],
  },
  {
    id: "archive-2025",
    name: "2025 Archive",
    role: "Viewer",
    status: "Unavailable",
    description: "Archived sample workspace",
    unavailable: true,
  },
];

function plainPrimary(event: MouseEvent<HTMLAnchorElement>) {
  return (
    event.button === 0 &&
    !event.metaKey &&
    !event.ctrlKey &&
    !event.shiftKey &&
    !event.altKey
  );
}

export function WorkspaceSwitcherDemo() {
  const uid = useId().replace(/:/g, "");
  const formId = `workspace-demo-form-${uid}`;
  const createId = `workspace-create-${uid}`;
  const manageId = `workspace-manage-${uid}`;
  const [query, setQuery] = useState("");
  const [open, setOpen] = useState(false);
  const [highlighted, setHighlighted] = useState<string | undefined>();
  const [activeId, setActiveId] = useState<string | null>("north-star");
  const [destination, setDestination] = useState<"create" | "manage" | null>(
    null,
  );
  const [status, setStatus] = useState("North Star is active.");
  const active = WORKSPACES.find((workspace) => workspace.id === activeId);

  return (
    <div className="workspace-switcher-demo">
      <form
        id={formId}
        action={`#workspace-result-${uid}`}
        onSubmit={(event) => {
          event.preventDefault();
          const data = new FormData(event.currentTarget);
          setStatus(
            `Prepared ${String(data.get("workspace") ?? "none")} locally.`,
          );
        }}
      />
      <TidalWorkspaceSwitcher
        label="Workspace"
        description="Search by workspace, role, or status."
        workspaces={WORKSPACES}
        query={query}
        open={open}
        highlightedWorkspaceId={highlighted}
        activeWorkspaceId={activeId}
        onQueryChange={(nextQuery) => {
          setQuery(nextQuery);
          setHighlighted(undefined);
        }}
        onOpenChange={setOpen}
        onHighlightedWorkspaceChange={setHighlighted}
        onWorkspaceChange={(workspace) => {
          setActiveId(workspace.id);
          setQuery("");
          setOpen(false);
          setStatus(`${workspace.name} is active in this preview.`);
        }}
        name="workspace"
        form={formId}
        createHref={`#${createId}`}
        createLabel="Create workspace"
        createLinkProps={{
          onClick: (event: import("react").MouseEvent<HTMLAnchorElement>) => {
            if (plainPrimary(event)) {
              setDestination("create");
              setStatus("Create workspace details opened locally.");
            }
          },
        }}
        manageHref={`#${manageId}`}
        manageLabel="Manage workspace"
        manageDisabled={!active}
        manageLinkProps={{
          onClick: (event: import("react").MouseEvent<HTMLAnchorElement>) => {
            if (plainPrimary(event)) {
              setDestination("manage");
              setStatus("Manage workspace details opened locally.");
            }
          },
        }}
      />

      <div className="workspace-switcher-demo-actions">
        <button type="submit" form={formId}>
          Use workspace
        </button>
        <button
          type="button"
          onClick={() => {
            setQuery("");
            setOpen(false);
            setHighlighted(undefined);
            setActiveId("north-star");
            setDestination(null);
            setStatus("North Star is active.");
          }}
        >
          Reset
        </button>
      </div>

      <section
        id={createId}
        className="workspace-switcher-demo-destination"
        hidden={destination !== "create"}
        aria-labelledby={`${createId}-title`}
      >
        <h3 id={`${createId}-title`}>Create workspace</h3>
        <p>A local sample destination. No workspace was created.</p>
      </section>
      <section
        id={manageId}
        className="workspace-switcher-demo-destination"
        hidden={destination !== "manage"}
        aria-labelledby={`${manageId}-title`}
      >
        <h3 id={`${manageId}-title`}>Manage {active?.name ?? "workspace"}</h3>
        <p>Role and access changes stay outside this preview.</p>
      </section>
      <p id={`workspace-result-${uid}`} role="status" aria-live="polite">
        {status}
      </p>
      <p className="workspace-switcher-demo-note">
        Sample workspaces. Changes stay in this preview.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <WorkspaceSwitcherDemo />
    </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."],"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."}

Consumer-owned workspaces require unique nonblank IDs, names, roles and statuses. Controlled query/open/highlightedWorkspaceId/activeWorkspaceId state proposes search, keyboard and pointer changes without navigation or persistence. Search matches only supplied IDs, names, roles, statuses and terms. Unknown active IDs fail through the Combobox input's linked error; malformed records fail visibly. Disabled or unavailable workspaces remain inspectable when active and cannot be newly selected. Optional native hidden input name/form serializes the exact active workspace ID. Native create/manage hrefs preserve modified navigation, expose independent disabled state, refs and anchor attrs, and perform no route or account action internally. Disabled destinations omit href, block primary and auxiliary activation, and leave the Tab order. Label, description, hint, error, input/toggle/hidden refs and safe native props, read-only selection, empty/outside-results states, 44px destinations, 16px narrow search, RTL, forced colors and reduced motion are supported.
