# CommandPalette

A Ctrl/Cmd+K menu for jumping to places and searching, with results in groups.

- **Use it for**: A Ctrl/Cmd+K jump-anywhere search for frequent users.
- **Not for**: The only way to reach pages. Try [Sidebar](https://unseenui.com/components/sidebar/), [NavigationMenu](https://unseenui.com/components/navigation-menu/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { CommandPalette } from '@stackunseen/ui/navigation';
import { Button } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';
import '@stackunseen/ui/navigation.css';

<CommandPalette items={jumps} search={searchSite} onSelect={(item) => router.push(item.href)} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `cancelLabel` | `string` |  |
| `debounceMs` | `number` |  |
| `defaultOpen` | `boolean` |  |
| `emptyState` | `ReactNode` |  |
| `footerHints` | `ReactNode` | Decorative key hints below the list; false hides them. |
| `highlight` | `false \| ((text: string, query: string) => ReactNode)` | Marks matches in labels; defaults to whole-word markMatches. |
| `items` | `readonly CommandPaletteItem[]` | Static entries, filtered locally: every word of the query must match the label, hint, group or keywords. |
| `label` | `string` | The dialog's accessible name. |
| `onOpenChange` | `((open: boolean) => void)` |  |
| `onSelect` | `((item: CommandPaletteItem) => void)` | Called for every selection. |
| `open` | `boolean` |  |
| `placeholder` | `string` |  |
| `search` | `((query: string, signal: AbortSignal) => Promise<readonly CommandPaletteItem[]>)` | Async results for the typed query. |
| `searchingLabel` | `string` |  |
| `shortcut` | `string \| false` | A key combination such as "mod+k" (mod is Ctrl or Command), or false for none. |
| `staticLimit` | `number` | How many static items to keep while a query is typed. |
| `trailingAction` | `((query: string) => CommandPaletteItem \| null)` | An item appended last while a query is typed, such as "Search everything for X". |

## Keyboard

Up and Down move and wrap, Home and End jump, Enter selects, Escape and the backdrop close. Enter does nothing during IME composition. Focus returns to the opener.

## Works with

[TableOfContents](https://unseenui.com/components/table-of-contents/), [Breadcrumb](https://unseenui.com/components/breadcrumb/), [Tabs](https://unseenui.com/components/tabs/), [Stepper](https://unseenui.com/components/stepper/), [Pagination](https://unseenui.com/components/pagination/), [DropdownMenu](https://unseenui.com/components/dropdown-menu/), [ContextMenu](https://unseenui.com/components/context-menu/), [NavigationMenu](https://unseenui.com/components/navigation-menu/), [Sidebar](https://unseenui.com/components/sidebar/), [ShareMenu](https://unseenui.com/components/share-menu/)

Page: https://unseenui.com/components/command-palette/
