On this page

InstallationUsageAnatomyIn a workspaceAt a tenant or an organizationA short trailA long nameCollapsedIn the dashboardAccessibilityAPI ReferenceContextSwitcherRulesWritten downOpen questionsWhat others adviseWhat others expose

Context switcher

Says where you are (an organization, a tenant or a workspace) and takes you somewhere else. It sits in the sidebar's header.

1<ContextSwitcher2  current={workspace}3  trail={[org, tenant, workspace]}4  onPick={goTo}5/>

Installation

text
import { ContextSwitcher } from "@dome-systems/ds-dashboard/patterns";

The switcher is the dashboard's own component, not a design-system one. It draws the trigger and the trail's menu; the picker it opens is a modal the caller provides, so the switcher goes inside a Modal.

Usage

text
<Modal>
  <ContextSwitcher
    current={current}
    trail={trail}
    onPick={goTo}
    backTo={backTo}
    onBack={goBack}
  />
  <ModalContent>{/* the context picker */}</ModalContent>
</Modal>

Anatomy

1234
  1. 1 — Card stack. Where you are and the levels above it, the current card on top, each in its kind's shade and glyph. Here: a tenant over its organization. It opens the trail's menu.
  2. 2 — Name. The current level's name, on one line. It opens the picker.
  3. 3 — Chevron. The small chevron, at the end of the name's button.
  4. 4 — Back. To the workspace this tab came from.

In a workspace

The stack draws where you are and the levels above it: the workspace's card on top, its tenant and organization behind. Point at the stack, or click it, and its menu lists the three. Point at the name and the cards wiggle once: the name opens the picker.

1<ContextSwitcher2  current={workspace}3  trail={[org, tenant, workspace]}4  onPick={goTo}5/>

At a tenant or an organization

current is the level you stand at. The cards below it leave the stack: a tenant shows its organization behind it, an organization stands alone. The trail keeps the workspace this tab came from, so the menu still lists it, and backTo adds a Back button that returns there. Its tooltip names the workspace.

1<ContextSwitcher2  current={tenant}3  trail={[org, tenant, workspace]}4  onPick={goTo}5  backTo="Design preview"6  onBack={goBack}7/>8<ContextSwitcher9  current={org}10  trail={[org, tenant, workspace]}11  onPick={goTo}12  backTo="Design preview"13  onBack={goBack}14/>

A short trail

An organization entered directly, with no remembered workspace under it, has no trail below it: the trail is that one level, and there is no Back. With fewer than two levels the stack is a picture, not a button.

1<ContextSwitcher current={org} trail={[org]} onPick={goTo} />

A long name

The name stays on one line and is cut at the chevron. Nothing shows the rest; see the open questions.

1<ContextSwitcher current={{ ...workspace, name: "Customer success automation, production" }} … />

Collapsed

In the icon-only sidebar, collapsed draws the current card alone. It opens the picker, and its tooltip is the current name. The trail's menu and Back are not offered there.

1<ContextSwitcher collapsed current={workspace} trail={trail} onPick={goTo} />

In the dashboard

The sidebar's header

ProjectPicker feeds the switcher: the context from the address, the trail from the workspace this tab came from. While a name has not loaded it shows "Organization", "Tenant" or "Select workspace". The sidebar mounts it in its header.

components/layout/project-picker.tsx

The trail's menu

The levels the stack moves between, three at most, each with a badge that says its kind. The current one is checked; picking it closes the menu and goes nowhere.

ds/dashboard/context-stack-menu.tsx

The picker

The dialog the name opens: a search box with New beside it (Organization, Tenant, Workspace), then Recent, Starred and All, the whole tree. Every context is here.

components/layout/context-picker-body.tsx

The trail

Which levels a tab offers: the workspace it came from and that workspace's parents. A tenant or an organization entered from a workspace keeps it.

lib/context-trail.ts

Accessibility

The name is a button. The stack is one too when the trail has two levels or more; with one it is a picture. The stack's menu opens when a pointer rests on it for 120ms, and on a click, Enter or Space. In the menu each level is read by its name and its kind, the current one as checked. The picker is a dialog titled "Switch context". Its organization and tenant rows are named for what they do ("Switch to organization Acme"); a workspace row is named by its name.

The trigger does not say where you are. The name button's spoken name is "Switch context" and the stack's is "Context trail": the name on screen is in neither, and the cards are hidden from a screen reader. Folded, the button is "Switch context" too and the name is its tooltip.

On the trigger the kind of the current level is shown by its card alone; in the menu it is also a word. Under reduced motion the cards do not wiggle or dip, and the menu does not fade.

API Reference

ContextSwitcher

A level is { kind, id, name }, with kind one of org, tenant and workspace.

PropTypeDefaultDescription
currentContextLevel—The level you stand at. Its name is the one shown.
trailContextLevel[]—The levels the stack's menu moves between, broadest first.
onPick(level) => void—A level was picked in the menu. Picking the current one never calls it.
backTostring—The name of the workspace Back returns to. Back shows whenever it is set; the dashboard sets it only up at a tenant or an organization.
onBack() => void—Back was pressed.
returningbooleanfalseBack was pressed and the page is on its way: the button is disabled.
collapsedbooleanfalseThe icon-only sidebar's switcher: the current card alone.

Rules

Written down

It shows the current context's name, always, in the sidebar's header

The workspace's name in a workspace, the organization's or the tenant's above one. It sits in the header with no box.

From design/information-architecture.md §6 and design/principles.md §7.

Two zones on one row

The name, the rest of the row, opens the picker; a small chevron at its end says it opens something. The card stack beside it is the shortcut: a menu of the trail. In the icon-only sidebar the current card alone opens the picker.

From design/information-architecture.md §6.

Back, only above a workspace

Up at a tenant or an organization, Back returns to the workspace this tab came from. Inside a workspace there is no Back.

From design/information-architecture.md §1 and §6.

What picking where you already are does

In the trail's menu the current row never commits. In the picker a current organization or tenant row does nothing, and the current workspace's row takes you to its home page.

From ui/dashboard/CLAUDE.md, URL and context model.

Nothing behind hover alone

The stack's menu opens on hover to save a click; a click, Enter and Space open it too.

From design/principles.md §6, keyboard parity.

While impersonating, no trail and no Back

The stack is a picture, Back is hidden, and the picker shows who the operator is viewing as, and Stop.

From ui/dashboard/CLAUDE.md, URL and context model.

Two places where the written sources disagree with each other. Where it sits: information-architecture §6 and principles §7 put the switcher in the sidebar's header, as built, while information-architecture §3 and principles §3 still describe a project picker at the right of the page header. Its motion: principles §5 lists every motion the dashboard may use and says anything else does not belong, while information-architecture §6 describes the cards' wiggle and dip, which are not on that list.

Open questions

Should a screen reader hear the context's name on the trigger?

Open
Ours

It does not today: the name button is "Switch context", expanded and folded, which replaces the name it shows. The trail's menu does read each name. Principles §2 allows an icon alone in the collapsed sidebar. Nothing written chooses the spoken name.

Other systems

Primer counts a navigation row's visible text as part of its spoken name. Atlassian asks for a meaningful label on a custom logo in its top navigation, and does not show the app's name at small widths.

How do you read a name that is cut?

Open
Ours

You cannot, expanded: a long name is cut with no tooltip. Only the folded switcher shows the name in a tooltip. The Table's rules put a tooltip where something is cut, for tables only; nothing written covers this row.

Other systems

Atlassian cuts too: its app name at 320px, a custom title at 200px.

Should a level be a link?

Open
Ours

A row in the menu calls a function, so it cannot be opened in a new tab, though every context has an address of its own. CLAUDE.md writes today's behavior (a switch is a document navigation); nothing asks for a link.

Other systems

Base UI has a menu row that is a link.

What others advise

None of this is decided for us. The pages read hold little advice on a switcher of organizations and workspaces; this is what they do say, listed so you can pick.

Others adviseWho
The sidebar's header, which stays at the top, is the place for a workspace switcher.shadcn
A custom logo or mark on the switcher keeps a meaningful label, so it has a spoken name.Atlassian
What a navigation row shows, its text and what trails it, is part of its spoken name.Primer

What others expose

What shadcn's team switcher, Base UI's menu and Atlassian's top navigation offer, and where ours stands on each.

They exposeOursWhy
Create, from the switcher (shadcn: "Add team", last in its menu)Already thereNew, beside the picker's search box: Organization, Tenant, Workspace.
Search in the list (Base UI: an input that filters a menu)Already thereThe picker's search box. The trail's menu has three rows at most.
Opening on hover, with its delays (Base UI)Already thereThe stack's menu: 120ms to open, 160ms to close.
The visible name in the trigger's spoken name (Primer, for navigation rows)AskOurs says "Switch context".
A second line under the name (shadcn: the team's plan; Atlassian: a secondary name)AskOurs shows the parents as cards, with no words.
A row that is a link (Base UI)AskOurs calls a function.
A logo of its own for each team or organization (shadcn; Atlassian lets admins upload one)AskOurs has one card per kind, not per place.
Number hints beside each team (shadcn prints ⌘1, ⌘2; its example wires no key)Ask⌘K lists every context today.
A title over the list (shadcn: "Teams")AskEach row's badge says its kind.