# CommandMenu

> A modal search palette over a flat vocabulary of items — grouped results, diacritic-insensitive filtering, match highlighting, and full keyboard navigation with focus that never leaves the search field.

- Package: `fancy-ui-react` (React 18/19 + Tailwind CSS v4)
- Category: Navigation
- Tags: command, palette, search, modal, listbox, accessibility
- Types: `CommandMenuProps`, `CommandItem`
- Docs: https://fancy-ui.rama.app/docs/components/command-menu
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/react/src/components/command-menu

## Import

```tsx
import { CommandMenu } from 'fancy-ui-react';
```

Setup (once per project): `npm install fancy-ui-react`, then put these lines in your main CSS file (the stylesheet import goes right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-react/tailwind.css";
```

and import the component styles once in the app entry: `import "fancy-ui-react/styles.css";`. Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in React; when one differs from the Svelte name, the Svelte name follows in parentheses. `class` becomes `className`, a callback takes the name the React port declares (`onclick` becomes `onClick`), snippets become `ReactNode` props (render functions when they take arguments) and the default snippet is `children`. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/react#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | `boolean` | `false` | Whether the menu is open; bindable |
| `onOpenChange` | `(open: boolean) => void` | — | Fires whenever open changes — Escape, an outside click, or committing an item |
| `items` (required) | `CommandItem[]` | — | The full, unfiltered vocabulary |
| `query` | `string` | `""` | The current search text; bindable. Reset every time the menu reopens |
| `onQueryChange` | `(query: string) => void` | — | Fires whenever query changes |
| `onSelect` | `(item: CommandItem) => void` | — | Called with the committed item, after that item's own onSelect |
| `placeholder` | `string` | `"Search..."` | Placeholder for the search field |
| `emptyMessage` | `string` | `"No results"` | Shown in place of the list when nothing matches |
| `label` | `string` | `"Command menu"` | Accessible name for the dialog and the search field |
| `filter` | `(item: CommandItem, query: string) => boolean` | — | Overrides the default case- and diacritic-insensitive substring filter entirely |
| `className` (Svelte `class`) | `string` | — | Additional CSS classes for the panel |
| `id` | `string` | — | The panel's id, for the aria-controls of a trigger rendered outside the component |
| `ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the panel element. |
| `sound` | `boolean` | `false` | Plays select on a committed row and close on a dismissal, once the user has enabled sound |

## Node props

| Prop | Description |
| --- | --- |
| `icon` | Rendered before each row's label, given that row's item. Treated as decorative |
| `empty` | Rendered in place of the list when nothing matches, instead of emptyMessage |

## Example

No React example is published for this component yet: start from the import above and the props table. The full examples are Svelte-only, on https://fancy-ui.rama.app/docs/components/command-menu.md.
