Skip to content
SuperCoach

Components · Navigation

Command

Beta

A search-driven command palette.

When to use

  • As a command palette for coaches who know what they want: type "add" and press Enter to add a client, or type a client's name and jump to their profile. In coach-admin it opens with ⌘K (Ctrl+K on Windows).
  • For a searchable list of actions and records in one place: "Add client", "Create program", "Review check-ins", then matching clients.
  • Inside a popover, as the list part of a Combobox.

This site's own search (⌘K in the header) is built on the same cmdk library.

When not to use

  • As the only way to reach something. Every command also exists as a button, link or menu item; the palette is a shortcut.
  • To pick one value in a form from a short list: use a Select. For a long list, use a Combobox, which is built from Command.
  • For actions on one item (a client row): use a dropdown menu.
  • For the main navigation: use the Sidebar.

Anatomy

  1. 1. Command: a search input above a list of results
  2. 2. Group heading: names the kind of result
  3. 3. Item: an icon and a label; the highlighted one runs on Enter
  4. 4. Shortcut (optional): the keyboard shortcut for the same action elsewhere

Not shown: the empty message, which replaces the list when nothing matches ("No actions or clients match."), and separators between groups.

Variants

VariantUse for
Inline (Command)A palette inside a page, a Popover or a combobox.
Dialog (CommandDialog)The app-wide palette. It's a Dialog with a Command inside: scrim, focus trap, Escape to close, and focus back to the trigger.

CommandDialog takes open and onOpenChange, plus a title and description for screen readers (visually hidden). Always pass them in the screen's language: the defaults are English ("Command Palette").

In coach-admin, open it from a button in the header and with ⌘K / Ctrl+K, registered once at the app level. This preview opens it from a button only, because ⌘K on this site opens the site search.

States

StateWhat changesToken
Highlighted item (arrow keys or pointer)Accent filldata-[selected=true]:bg-accent, text-accent-foreground
Disabled itemHalf opacity, skipped by arrow keysopacity-(--opacity-disabled)
Group headingSmall muted texttext-xs, font-medium, text-muted-foreground
ShortcutSmall muted text, wide trackingtext-xs, tracking-wide, text-muted-foreground
Input placeholderMuted textplaceholder:text-muted-foreground
SurfacePopover colorsbg-popover, text-popover-foreground
EmptyThe empty message replaces the list—
LoadingUse Command.Loading from cmdk while results load—

Type a name that isn't in the first preview, such as "Noura", to see the empty state.

Usage guidelines

  • Put actions first, then records (clients, programs), each in its own group.
  • Show a few useful suggestions before the coach types: the most used actions and recent clients.
  • Run the command on Enter and close the dialog. If the action opens something, focus moves there.
  • Shortcuts in items are hints for the same action elsewhere. Only show shortcuts that really exist.
Do.Grouped, with verbs for actions and names for records.
Client
Program
Sara Al-Harbi
Don't.Actions and records mixed in one list, with nouns that don't say what happens.

Content guidelines

  • Actions start with a verb, like buttons: "Add client", "Create program". Records use their name: "Sara Al-Harbi".
  • The placeholder says what can be found: "Search actions and clients…". Not just "Search…".
  • Group headings are plural nouns: "Actions", "Clients", "Programs".
  • The empty message says what didn't match, without blame: "No actions or clients match."
  • Arabic: actions use the verbal noun, like buttons: "إضافة عميل"، "إنشاء برنامج".

Accessibility

KeyDoes
TypingFilters the list as you type; the first match is highlighted
Arrow down / upMoves the highlight. Focus stays in the input
Home / EndFirst / last item
Ctrl+N / Ctrl+P (also Ctrl+J / Ctrl+K)Next / previous item, as in Emacs and Vim. Turn these off with vimBindings={false} where Ctrl+K also opens the palette
EnterRuns the highlighted item
EscapeIn a CommandDialog, closes it and returns focus to the trigger
  • The input is a combobox that controls a listbox; items are options, and the highlight is aria-activedescendant, so focus never leaves the input. Moving the highlight reads "Create program, 2 of 3".
  • Label the input with label on Command (a visually hidden label). CommandList is named "Suggestions" from the UI labels, in Arabic on Arabic screens.
  • CommandDialog passes its title to its Command as the label, and renders the title inside the dialog, so both the dialog and the input are named ("Command palette" by default, from the UI labels). Upstream rendered the title outside the dialog and left the input unlabelled.
  • Group headings are hidden from screen readers and label their group instead: "Clients, group".
  • The empty message is not announced. If it matters, also update a role="status" region with the result count.
  • Shortcuts are hints only. The palette doesn't register them.

RTL

The input, items and group headings align to the right, and the search icon sits at the start. Arrow keys are vertical, so they don't change. The shortcut sits at the far end of each item (ms-auto; upstream used ml-auto, which put it right after the label in RTL). Shortcut text such as "⌘B" stays left to right.

Tokens used

Read from components/ui/command.tsx at build time, so this list changes when the component does. Opacity modifiers such as /90 are shadcn hover and focus tints on top of the token.

Semantic color tokens used by this component
TokenUtilitiesSuperCoachCoach
--accentbg-accentbrand-50orange-50
--accent-foregroundtext-accent-foregroundbrand-700orange-700
--borderbg-borderneutral-200neutral-200
--foregroundtext-foregroundneutral-950neutral-950
--muted-foregroundtext-muted-foregroundneutral-600neutral-600
--popoverbg-popoverwhitewhite
--popover-foregroundtext-popover-foregroundneutral-950neutral-950
  • Opacityopacity-(--opacity-disabled)
  • Radiusrounded-md
  • Radiusrounded-sm
  • Typefont-medium
  • Typetext-sm
  • Typetracking-wide
  • Typetext-xs

Props

<Command>

Also takes every prop of cmdk Command

No props of its own.

<CommandDialog>

Also takes every prop of <Dialog>

CommandDialog props
PropTypeDefault
title?string—
description?string—
className?string—
showCloseButton?booleantrue

<CommandShortcut>

Also takes every prop of <span>

No props of its own.

Command, CommandInput, CommandList, CommandGroup, CommandItem, CommandEmpty and CommandSeparator take the props of the matching cmdk parts: see the cmdk documentation. The useful ones: label (Command, CommandList), filter, shouldFilter and loop (Command), heading (CommandGroup), value, keywords, onSelect and disabled (CommandItem).

Replaces in coach-admin

The audit found no styles for this component in coach-admin.

coach-admin has no command palette today. This is a new capability, not a replacement.

Combobox, Dialog, Popover, Dropdown menu, Sidebar.