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.
<ContextSwitcher current={workspace} trail={[org, tenant, workspace]} onPick={goTo}/>Installation
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
<Modal>
<ContextSwitcher
current={current}
trail={trail}
onPick={goTo}
backTo={backTo}
onBack={goBack}
/>
<ModalContent>{/* the context picker */}</ModalContent>
</Modal>Anatomy
- 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 — Name. The current level's name, on one line. It opens the picker.
- 3 — Chevron. The small chevron, at the end of the name's button.
- 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.
<ContextSwitcher current={workspace} trail={[org, tenant, workspace]} onPick={goTo}/>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.
<ContextSwitcher current={tenant} trail={[org, tenant, workspace]} onPick={goTo} backTo="Design preview" onBack={goBack}/><ContextSwitcher current={org} trail={[org, tenant, workspace]} onPick={goTo} backTo="Design preview" onBack={goBack}/>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.
<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.
<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.
<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.
| Prop | Type | Default | Description |
|---|---|---|---|
current | ContextLevel | — | The level you stand at. Its name is the one shown. |
trail | ContextLevel[] | — | 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. |
backTo | string | — | 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. |
returning | boolean | false | Back was pressed and the page is on its way: the button is disabled. |
collapsed | boolean | false | The 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?
OpenIt 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.
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?
OpenYou 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.
Atlassian cuts too: its app name at 320px, a custom title at 200px.
Should a level be a link?
OpenA 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.
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 advise | Who |
|---|---|
| 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 expose | Ours | Why |
|---|---|---|
| Create, from the switcher (shadcn: "Add team", last in its menu) | Already there | New, beside the picker's search box: Organization, Tenant, Workspace. |
| Search in the list (Base UI: an input that filters a menu) | Already there | The picker's search box. The trail's menu has three rows at most. |
| Opening on hover, with its delays (Base UI) | Already there | The stack's menu: 120ms to open, 160ms to close. |
| The visible name in the trigger's spoken name (Primer, for navigation rows) | Ask | Ours says "Switch context". |
| A second line under the name (shadcn: the team's plan; Atlassian: a secondary name) | Ask | Ours shows the parents as cards, with no words. |
| A row that is a link (Base UI) | Ask | Ours calls a function. |
| A logo of its own for each team or organization (shadcn; Atlassian lets admins upload one) | Ask | Ours 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") | Ask | Each row's badge says its kind. |