Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Environment Switcher Command Menu Block for React

A 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.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Put a guard in front of the one environment that matters with this environment switcher command menu for React with Base UI. It opens from the Deploys page of Tiergate, a deploy 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 environment pill, and a list of deploys made of shapes. The menu is the catalog Command. It lists Local, Preview, Staging and Production, each with its branch in monospace and the day it was last deployed, and a foot that says which environment the console is on, "Current: Staging". Choosing the first three switches the pill at once. Choosing Production does not: the menu turns into a confirm step in the same shell, "Switch to Production? This changes live data.", with an Input that wants the word production, a destructive Button, "Switch to Production", and Escape or Back to go back. Only when the word matches and you press the button does the pill read Production, with an outline. Nothing is deployed. 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 and step. For deploy consoles, feature-flag tools, databases with a live copy and any product where one environment is not like the others.

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, 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, the step and the word 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 confirm step work?

Production is the only guarded row. Choosing it sets the step to confirm and the menu body is swapped for a form of the same size, so nothing around it moves. The field wants the word production, ignoring case and spaces around it, and the line under it says whether what you typed matches. The destructive button is always there but aria-disabled until it matches; pressing it, or pressing Enter in the field, before then says "Type production to switch." and puts focus back in the field instead of doing nothing.

What does Escape do in the confirm step?

It goes back to the list and the menu stays open, so one slip does not close everything; Escape again closes the menu and puts focus on the field. In the real dialog a click outside the dialog also steps back first. The Back button does the same as Escape, and the status line says which environment you are still on.

Why does the destructive button look the way it does?

The catalog's destructive button draws its red text on a faint red tint, which falls under AA in light and dark. Once the word matches, the block pulls the text toward the foreground so it reads at AA on its tint in both themes; before that the button is a quiet grey that says it is not ready. The block has no primary button, as a destructive confirm should not.

What stays local, and how do I wire it?

Everything. Switching changes the pill and the status line and nothing else: nothing deploys, no environment changes and nothing is saved. In your app pick and confirm are where the console would change its target; keep the typed word on the server side too, since a field in a browser is a guard for people, not a lock.

Is it accessible from the keyboard?

Yes. Type to search, the arrow keys move, Enter chooses and Escape closes or goes back; Ctrl or ⌘ K opens the dialog while focus is inside the block, and only then. When the confirm step opens, focus moves to its field. The rows are options of a cmdk listbox; the block turns off its own fuzzy filter and lists the rows itself.

  • Pro

    A 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.

  • Pro

    Environment Switcher Navbar

    Accounts and scopes

    An app bar with a Production, Staging and Development segment control that shows the environment's base URL with a copy button and asks for confirmation before switching to Production.

  • Pro

    Downgrade Confirmation Billing

    Upgrade and downgrade

    A downgrade that shows what it costs first: the limits that shrink, the folders now over the smaller plan's storage with a checkbox to archive each and a live meter, the day it takes effect, and an alert dialog that asks for a typed word.

  • Pro

    An 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

    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.

  • Pro

    A language-learning app's language menu as a command menu shown open above the language button in a lesson page's foot: ten languages by their own names with lang and dir set, a completeness bar and percent, search in any script, and a lesson page whose labels flip.