Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Command examples · Popover

Command Popover with Status Indicators for React

A View Services button that opens a command popover of services, each with a colored status dot and its state.

Framework
UI library

Four services, each with a colored dot and its state: Running, Warning or Stopped. The word says what the color says, so the state never rests on color alone. The View Services button opens the menu in a Popover below the button, so the menu stays next to what it acts on. In React, Base UI handles the keyboard navigation.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How is this menu anchored to the button?

The View Services button is the trigger, and the panel opens below it, lined up with its start edge. The panel is 400px wide, never wider than the screen, and has no padding, so the Command fills it. A visually hidden PopoverTitle names it. PopoverTrigger renders the button through render, and PopoverContent sets align="start".

How is the colored status dot built?

Each dot is a span with size-3 shrink-0 rounded-full and a theme color: bg-success for API Server and Database, bg-warning for Cache Server, and bg-destructive for Queue Worker. It's hidden from screen readers, because the state is written out beside it.

Where does Running or Stopped go?

The service name's span has flex-1, which pushes the state to the end of the row. The state is a span with text-muted-foreground text-xs that reads Running, Warning or Stopped.

What appears when nothing matches the search?

CommandEmpty in the list says "No services found." It shows only when the search leaves nothing.

How do I run an item from this menu in React?

These items don't run anything yet. Pass onSelect to each CommandItem.

How do the keys work in this menu?

The arrow keys move through the items, Enter runs the highlighted one, and typing filters the list. Escape or a click outside closes the popover, and focus goes back to the button. CommandInput shows "Search services..." until someone types. Command filters and ranks the items by their text on its own.