UI.MD

Command

A command palette for searching and executing actions. Built on cmdk.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/command.json

Usage

import { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator, CommandShortcut } from "@/components/ui/command"

Examples

Default

Dialog (⌘K)

The modal command palette. CommandDialog wires the title and description for accessibility; bind ⌘K to toggle it.

API Reference

PropTypeDefaultDescription
titleCommandDialogstring"Command Palette"Screen-reader title for the palette, rendered visually hidden.
descriptionCommandDialogstring"Search for a command to run..."Screen-reader description for the palette, rendered visually hidden.
showCloseButtonCommandDialogbooleantrueShows the close button in the dialog's top-right corner.
shouldFilterCommandbooleantrueWhether cmdk filters and ranks items against the search query. Set false to filter results yourself.
filterCommand(value, search, keywords) => number-Custom ranking function; return 0 to hide an item, higher scores rank first.
loopCommandbooleanfalseWraps keyboard navigation from the last item back to the first.
headingCommandGroupReact.ReactNode-Label rendered above the group's items.
valueCommandItemstring-Explicit value used for filtering and selection; defaults to the item's text content.
onSelectCommandItem(value: string) => void-Called when the item is chosen via click or Enter.
disabledCommandItembooleanfalseDisables the item so it can't be selected.