Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Command Popover with Status Indicators for Svelte

An outline View Services button that opens a popover of services with a colored dot and a state on each row.

UI library: Ark UI

An outline View Services button opens the popover. Four services show a colored dot and a word: Running, Running, Warning, and Stopped.

Keep the popover beside the control that asked for status. Open a Dialog when the list should cover the rest of the page. In Svelte, Ark UI does not change the page.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Command anatomy: root, input, group label, list, item, shortcut

Usage

<Popover onOpenChange={handleOpenChange} positioning={{ placement: "bottom-start" }}><PopoverTrigger>{#snippet asChild(props)}<Button {...props()} variant="outline">View Services</Button>{/snippet}</PopoverTrigger><PopoverContent class="w-[400px] max-w-[calc(100vw-2rem)] p-0"><PopoverTitle class="sr-only">View Services</PopoverTitle><Command collection={collection} onInputValueChange={handleInputValueChange}><CommandInput placeholder="Search services..." /><CommandContent><CommandList><CommandEmpty>No services found.</CommandEmpty><CommandGroup heading="Services">{#each collection.items as item (item.value)}<CommandItem item={item}><span aria-hidden="true" class={cn("size-3 shrink-0 rounded-full", item.dot)}></span><span class="flex-1">{item.label}</span><span class="text-muted-foreground text-xs">{item.status}</span></CommandItem>{/each}</CommandGroup></CommandList></CommandContent></Command></PopoverContent></Popover>

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. asChild is a snippet on PopoverTrigger that renders the button, and positioning on Popover sets placement: "bottom-start". When the popover closes, the demo clears the filter.

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 Svelte?

These items don't run anything yet. Handle onValueChange on Command, which receives the chosen item's value, and keep value empty so every choice fires.

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. The filtering is the demo's: it builds the items with useListCollection and a contains filter, and calls filter with the input's value as it changes.

API Reference

Popover

Sets onOpenChange={handleOpenChange}, positioning, placement and bottom-start. The rest is on the Popover page.

Button

Sets props and variant="outline". The rest is on the Button page.

Command

Sets collection={collection}, onInputValueChange={handleInputValueChange}, placeholder="Search services...", heading="Services" and item={item}. The rest is on the Command page.