Skip to content

CommandPalette

Stable

A search box and a list of actions in a modal window. Type to narrow the list, then press Enter.

Also known as command menu, command k, cmd k, spotlight

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Grouped commands opened by a button

Last command: Nothing yet

Commands under a group name get a heading. Typing narrows the list, matches at the start of a label come first, and a disabled command is shown but skipped by the arrow keys.

When to use it

Gives quick, keyboard-first access to many actions without a menu for each. Typing narrows the list and Enter runs the top choice.

Made of: Backdrop · Panel · Search field · Esc hint · Group heading · Option (icon, label, hint, shortcut) · Empty message

Use it for

  • An app with many actions that people would rather type than hunt for.
  • Jumping between places, or running an action from the keyboard.
  • Showing shortcuts people can learn over time.

Not for

  • A short menu of actions for one item: use ToolMenu.
  • A small panel of choices next to a button: use Popover.
  • A confirm or a form: use Dialog.

Do and avoid

new
New invoiceN
New clientC
Do. Typing narrows a list of clearly named actions.
export
ExportE
ExportX
Avoid. Two commands with the same name, so people cannot tell them apart.

Do

  • Add a visible button that opens it, as well as any shortcut.
  • Group commands under short headings.
  • Add keywords for the other names people might type.
  • Show a shortcut only when it really works.
  • Keep labels short and start them with a verb or a place.

Avoid

  • Do not make it the only way to reach an action.
  • Do not register a shortcut inside it. Your app owns that.
  • Do not use it for a form or a confirm. Use a Dialog.
  • Do not put long text or controls inside an option.
  • Do not give two commands the same label.

On a phone

  • The palette fills the width with a 12px margin and sits at the top, taking up to the full screen height; from 640px it is centered lower and capped at 30rem.
  • The search field is 16px so the page does not zoom, the Esc hint is hidden on a phone, and results scroll inside the list.
  • Result rows are 44px tall on a touch screen, and the shortcut hints on each row are hidden on a phone.
  • There is no keyboard shortcut to open it on a phone, so give people a button that opens it.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started