Skip to content
Knowns UI
Get ProSign in

Team Switcher

Move between teams or workspaces from the top of an app. The trigger shows the team you are in with its plan and size; the menu shows the rest with your role, finds one by name once the list grows, takes Cmd or Ctrl + 1 to 9, accepts an invite and creates a team. It folds to the mark alone in an icon rail.

On this page
Used for
  • Top of an app sidebar
  • Workspace picker
  • Icon rail
  • Accepting an invite
  • Org switch in a header

Examples

Past six teams the menu opens with focus in a search field. Type to narrow by name, plan or role; the arrows still move through the rows and Enter picks. Esc clears the search first, then closes. Change the cut with searchThreshold.

In an icon rail

collapsed keeps only the mark. The team's name and plan become the trigger's accessible name and its tooltip, and the menu opens to the right of the rail.

With a pending invite

Invitations sit under your teams with who sent them and the role offered. Enter or a click on the row accepts; a promise from onAcceptInvite keeps the menu open with a spinner until it settles. Here the team joins the list and becomes current.

In the sidebar

The Sidebar block's SidebarSwitcher is this component: it takes workspaces and the same props, follows the rail, and leaves search and the shortcuts off unless you pass searchThreshold and shortcuts.

Installation

npx knowns-ui@latest add team-switcher
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

teams
Team[]
{ id, name, plan?, role?, members?, description?, src?, icon?, swatch? }. plan and members make the trigger's second line, role and plan the row's; description is used when there are none.
value
string
Id of the current team. It gets the check, and the menu opens on it.
onChange
(id) => void
A team was picked, by click, Enter or its shortcut.
onCreate
() => void
Shows the Create row at the bottom.
createLabel
string
Default"Create team"
Text of the Create row.
invites
TeamInvite[]
{ id, team, invitedBy?, role? }. Listed under Invitations when onAcceptInvite is set.
onAcceptInvite
(id) => unknown
Accept an invite. A promise keeps the menu open with a spinner until it settles.
searchThreshold
number | false
Default6
Show the search field when there are more teams than this.
searchPlaceholder
string
Default"Find a team"
Placeholder of the search field.
shortcuts
boolean
Defaulttrue
Cmd (Mac) or Ctrl + 1..9 pick the first nine teams from anywhere on the page, and the menu shows the keys. Turn it off when two switchers share a page.
collapsed
boolean
Defaultfalse
Mark only, for a rail, with the name in a tooltip and the accessible name.
expanded
boolean
Defaultfalse
The list open in the flow as a radiogroup card, instead of a menu.
label
string
Default"Switch team"
Accessible name of the menu, and part of the collapsed trigger's name.
groupLabel / invitesLabel
string
Default"Teams" / "Invitations"
Small labels over the two groups.
align / side
"start" | "end" / "auto" | "bottom" | "top" | "right"
Default"start" / "auto"
Where the menu opens. Collapsed defaults to the right.
width
number
Default288
Menu width in px, never wider than the screen less 16px.
open / onOpenChange
boolean / (open) => void
Control the menu from outside.
textWrap
ComponentType
Wraps the trigger's text and chevron, for a host that animates them itself (the sidebar's rail).
className
string
Classes on the trigger.

Accessibility

  • The trigger is a button with aria-haspopup and aria-expanded. Down or Up opens the menu, which lands on the current team.
  • Without search the list is a menu of menuitemradio rows, with the current team checked. With search the field is a combobox over a listbox, and the current team carries aria-current.
  • Focus stays on the list or the field and the active row is aria-activedescendant: arrows, Home, End, type-ahead by the first letters, Enter to pick, Esc to clear the search and then close, Tab to leave. Focus goes back to the trigger.
  • Each row with a shortcut names it in aria-keyshortcuts. An invite row reads as "Accept invite to Tidewater Analytics as Editor", and joining is announced while it runs.
  • Collapsed, the trigger's name is the team, its plan and size, and "Switch team".

What it handles

  1. 01Shows the current team as a trigger: its mark, name, plan and member count, and a chevron.
  2. 02Shows every team with its mark, your role and its plan, and a check on the one you are in.
  3. 03Opens with a search field once there are more than six teams, and keeps Invitations and Create in place while you filter.
  4. 04Switches with Cmd or Ctrl + 1 to 9 from anywhere on the page, and shows each key in the menu.
  5. 05Shows pending invitations with an Accept button, and keeps the menu open with a spinner while your call runs.
  6. 06Folds to the mark alone for an icon rail, with the name in a tooltip and in the trigger's accessible name.

States

First render
Nothing moves
none
Open and close
The menu fades in, and out a little faster
120ms in, 80ms out, ease out
Move through rows
The highlight jumps to the row, no glide
none
Team switched
The trigger's mark pops in and its name rises 4px into place; with the menu open, the check pops on the new row
180ms, spring for the pops, ease out for the text
Accepting an invite
A spinner turns on the Accept button until your call settles
spinner
Invite accepted
The button turns green, a check pops from small past its size and Joined rises in; the new team's row eases 6px into the list, and a beat later the invite row folds away and the highlight moves to the new team
420ms check, then 120ms fold; the rise is 180ms; about 600ms in all
Rail tooltip
Fades in and out like the menu
120ms, ease out
Hover
The trigger's fill darkens a step
120ms, ease out
Reduced motion
Everything appears at once
0ms

Works with

When to use

When to use

  • The top of an app sidebar or header when people work in several teams or workspaces: which one they are in, its plan and size, and a quick way to the others.
  • An app where people belong to many orgs: search by name, Cmd or Ctrl + 1 to 9, and pending invites accepted in place.

When not to use

  • The signed-in person's own account and sign out: use User Menu.
  • A whole navigation column with the switcher on top: use Sidebar.
  • Picking a value inside a form: use Combobox.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Team Switcher to my app and wire it to my own data.
  • I need the top of an app sidebar or header when people work in several teams or workspaces: which one they are in, its plan and size, and a quick way to the others. Set that up with the Knowns UI Team Switcher.
  • Which Team Switcher props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "team-switcher" }) and search_docs({ query: "team switcher" }).

Need help?

Stuck on Team Switcher, or found something off? We read every message.