Navigation Core Stable

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.

Preview

Installation

pnpm add fancy-ui-svelte
import { CommandMenu } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { CommandMenu } from 'fancy-ui-svelte';
</script>

<CommandMenu />

Examples

Basic Usage

Grouped Items

Items with no group render first, then each group under its own heading.

Empty State

The message shown when nothing matches the query.

Custom Filter

Replacing the default filter entirely, e.g. with a prefix match.

With Keywords

Matching on keywords that never appear in the visible label.

Props

PropTypeDefaultDescription
open booleanfalseWhether the menu is open; bindable
onOpenChange (open: boolean) => void-Fires whenever open changes — Escape, an outside click, or committing an item
items *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
class string-Additional CSS classes for the panel
ref HTMLDivElement | nullnullBindable reference to the panel element.

Slots

SlotDescription
iconRendered before each row's label, given that row's item. Treated as decorative
emptyRendered in place of the list when nothing matches, instead of emptyMessage