shadcn.io is not affiliated with official shadcn/ui
Project Switcher Command Menu Block for React
A git client's project switcher as a command menu shown open at the centre of the title bar: pinned and recent repositories with branch, host, ahead and behind, a switch that keeps only projects with changes, and a title bar and file tree that follow the choice.
Installation
Overview
Jump between repositories without leaving the keyboard with this project switcher command menu for React with Base UI. It opens from the Editor page of Repohill, a git desktop client, whose header holds an outline field with its ⌘ K cap, and the client is drawn under a soft scrim inside a hairline frame with a plus mark on each corner: a title bar whose centre names the project and its branch, an explorer with a file tree and an open file made of shapes. The menu hangs from the title bar and is the catalog Command. Repositories are grouped under Pinned and Recent, and each row has a two-letter tile for where it is hosted, the name, the branch in monospace, "2 ahead, 0 behind" and "3 changed" as words, never colours. A Switch above the search, Only projects with changes, filters the list and says how many that is. Choosing a project swaps the title bar and the explorer's file tree, one of three typed trees, and the status line says so. Nothing is opened, cloned or fetched. For preview the menu is drawn open in place when the page loads; the field, or Ctrl or ⌘ K while focus is in the block, opens the real command dialog with the same rows, switch and query. For git clients, IDEs, deploy tools and any product with a handful of things you move between all day.
FAQ
Why is the menu already open, and what do I keep?
So you can see it without a click. On load the menu is the Command drawn inline under the drawn title bar, in a plain shell that is not modal, so nothing is trapped, hidden or focused and the page around the preview keeps working. The header's field opens the real command dialog, modal, with its focus trap, Escape and focus return, and the inline copy stays closed until a reload. Both show the same Palette and share the block's state, so the switch and what you typed in the copy are in the real dialog. In your app keep the dialog and drop the copy: the "in-place" state, the scrim with its shell and the Escape and blur effects.
How does the switch filter the list?
Turning it on keeps the projects whose changed count is above zero, so the list, the foot ("3 of 6 projects") and the line beside the switch ("3 of 6") all come from the same data. The switch sits above the input and outside the Command, so its keys never fight the list's: Tab reaches it, Space turns it on, and the change is said aloud. A search with nothing left says whether the switch is the reason and offers to turn it off.
What changes when I choose a project?
The drawn title bar shows the project's name and branch, and the explorer shows one of three typed file trees (a service, an app or a docs site), so two projects of the same kind share a tree. The drawing is hidden from assistive technology, so the status line carries the same facts: "Switched to wendlow-docs on docs/search-page. In this demo only." Nothing is opened, cloned or checked out.
What stays local, and how do I wire it?
All of it. The repositories, their branches, the ahead, behind and changed counts and the trees are typed data; no repository is read and no git command runs. In your app the counts come from git status and git rev-list, the hosting tile from the remote's URL, and pick is where the client would open the repository.
Is it accessible from the keyboard?
Yes. Type to search by name, branch or host, the arrow keys move, Enter switches to the highlighted project and Escape closes the menu and puts focus on the field; Ctrl or ⌘ K opens the dialog while focus is inside the block, and only then. The rows are options of a cmdk listbox; the block turns off its own fuzzy filter and lists the rows itself.
How does it look on a phone?
The explorer goes and the title bar stays. The copy shown on load docks to the top of the page at full width, so the keyboard does not cover the foot; the key hints go and the count stays. Each row moves its ahead, behind and changed words under the branch instead of keeping them at the end. The real dialog keeps the Command dialog's own phone layout.
Related
- Pro
Workspace Switcher Command Menu
SwitchersA knowledge base's workspace switcher as a command menu shown open under the switcher at the head of the sidebar: member counts, a star that pins a workspace live into a Pinned group, and a Create row that adds a new workspace from what you typed and switches to it.
- Pro
Recent Items Command Menu
Search everythingA project hub's command menu shown open on what you opened lately: Today, Yesterday and Earlier buckets before you type, recent matches first when you do, opening a row moves it to the top, and a last row clears the list.
- Pro
Quick Open Files Command Menu
Search everythingA cloud drive's quick open as a command menu shown open at the top of a file manager: recent files first, a search across every folder, middle-shortened paths with sizes and dates, kind chips and a sort, and the chosen row selected in the table behind.
- Pro
Environment Switcher Command Menu
SwitchersA deploy console's environment switcher as a command menu shown open on the deploys page: Local, Preview, Staging and Production with branch and last deploy, and a typed-word confirm step with a destructive button before Production switches.
- 1234Pro
Account Switcher Command Menu
SwitchersAn agency billing portal's account switcher as a command menu shown open under the account chip: four accounts with initials, role and plan, a tick on the current one, the keys 1 to 4 to switch straight to an account, and the chip and status line that follow the choice.
- Pro
Connection Switcher Command Menu
SwitchersA database client's connection switcher as a command menu shown open over a query editor: five connections with engine, host, database and a state in words, a Test button or Alt T that runs a simulated test with a spinner and a typed result, and a toolbar chip that follows the choice.