shadcn.io is not affiliated with official shadcn/ui
View As Command Menu Block for React
A support console's view-as switcher as a command menu shown open under the avatar: You and Teammates with initials, role and queue size, a read-only banner with an Exit button, and a ticket list that shows only that person's queue.
Installation
Overview
Let a lead see the product the way a teammate does with this view-as command menu for React with Base UI. It opens from the Tickets page of Proxyhill, a support console, whose header holds an outline field with its ⌘ K cap, and the console is drawn under a soft scrim inside a hairline frame with a plus mark on each corner: a bar that ends in an avatar, a row of filters and a list of tickets made of shapes. The menu hangs from the avatar and is the catalog Command. It has two groups, You and Teammates, and each person is an initials Avatar with a name, a role and how many tickets are in their queue, counted from the data. Choosing a teammate puts the console into view-as mode: a banner across the bar says "Viewing as Jun Okafor. Read-only." with an Exit Button, the avatar shows their initials, and the list holds only their tickets. Exit, or choosing yourself, puts it back. Nobody is impersonated. 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. For support tools, admin consoles, school dashboards and any product where one person needs to check what another sees.
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 avatar, 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 query and the person you chose are the same in the 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.
What does view-as mode change?
Three things, all drawn: the banner across the bar, naming the person and saying it is read-only; the avatar, which shows their initials; and the list, which shows only that person's tickets, so a queue of two shows two rows. The banner is a real region with a real Exit button named for the person, "Exit view as Jun Okafor"; the drawing under it is hidden from assistive technology, so the status line and the banner carry the meaning.
How do I leave view-as mode, and where does focus go?
Press Exit in the banner, or open the menu and choose yourself. Exit removes the banner, so focus goes to the field in the header that opens the menu, never to the page behind. Choosing yourself closes the menu and focus returns the same way. The status line says which, and says "Already viewing your own queue." if you were not viewing anyone else.
What stays local, and how do I wire it?
All of it. Nobody is impersonated: there is no session change, no request and no audit entry, and the tickets are typed data counted by owner. In your app view-as is a security feature, so it belongs on the server: a short-lived read-only session, an audit log entry and the same banner on every page. Keep pick and exit as the two places that start and end it.
Is it accessible from the keyboard?
Yes. Type to search by name or role, the arrow keys move, Enter views as the highlighted person 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 person you are viewing is ticked and says so for screen readers. 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 copy shown on load docks to the top of the page at full width under the bar, so the keyboard does not cover the foot; the key hints go and the count stays. The banner keeps its text and Exit button across the bar and grows to two lines when it needs to. The real dialog keeps the Command dialog's own phone layout.
Related
- 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
Account Menu Navbar
Accounts and scopesAn app bar with an account button behind a split divider that opens a menu: an identity header with plan badge and storage bar, a Switch account radio list, and Profile, Settings, Billing and Sign out.
- Pro
Account Delegation Account
Shared accessThe people who can act on an account as a matrix: a row for each delegate with a box for each of four scopes, pending invitations with Resend, an invitation form whose role ticks the scopes, and Undo.
- 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.
- 333Pro
Global Search Command Menu
Search everythingA company intranet's command menu shown open: one input searches pages, docs, people and tags at once, each type is a group of three matches with a row that opens it in place, and the foot counts the results by type.
- 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.