Navigation

Command Palette

Search everything, run anything. The fastest way through an app — and the signature component of juxt.ui.

Installation #

With the Nuxt module, every component and composable is auto-imported — there is nothing to add. In a plain Vue project, import what you use:

Copy
import { JCommandPalette, useRecentCommands } from '@juxtui/ui'

Usage #

Copy
<JCommandPalette v-model:open="open" :groups="groups" @select="run" />

⌘K on macOS and Ctrl K elsewhere toggles the palette from anywhere on the page. Change it with hotkey, or pass false.

Built-in ranking orders results the way people expect: exact, then prefix, then word start, then substring, then letters in order — and the matched characters are highlighted.

Every keystroke puts the best match under the cursor, so Enter almost always does what you meant.

Variants & examples #

Set :filter="false", watch v-model:search, and toggle loading while you fetch.

Recent items#

useRecentCommands remembers what was used, per browser. Pass the result to recent.

API #

Props

PropTypeDefault Description
openbooleanfalseBound with v-model:open.
groupsCommandGroup[]—{ id, label?, items: CommandItem[] }.
searchstring''Bound with v-model:search. Cleared on open.
recentCommandItem[]—Shown as a “Recent” group while the search is empty.
placeholderstring'Type a command or search…'Search placeholder.
loadingbooleanfalseShows a progress hairline, and “Searching…” when empty.
filterbooleantrueBuilt-in ranking. Turn off to filter yourself.
hotkeystring | false'mod+k'Global shortcut that toggles the palette.
labelstring'Command palette'Accessible name.
emptyTextstring'No results'Empty state title.

Events

EventPayload Description
selectCommandItemAn item was chosen. The palette closes.
update:openbooleanOpen state changed.
update:searchstringSearch text changed.

Slots

SlotProps Description
item{ item, active }Custom row content.
empty{ search }Custom empty state.
footer—Replace the keyboard hints.

CommandItem

PropTypeDefault Description
idstring—Unique within its group.
labelstring—Main text; matched and highlighted.
descriptionstring—Muted text after the label; also searchable.
iconComponent—Rendered at 16px.
shortcutstring—Display-only shortcut, e.g. mod+shift+p.
keywordsstring[]—Extra terms that should find this item.
disabledboolean—Shown but not selectable.
onSelect(item) => void—Called before select is emitted.

useRecentCommands(options?)

Functions

MethodSignature Description
record(id)(id: string) => voidRemember an item as most recent.
resolve(items)(items: T[]) => T[]Map remembered ids back to items, most recent first.
clear()() => voidForget everything.
options{ key?, limit? }localStorage key (default juxt:recent-commands) and how many to keep (default 5).

Accessibility #

  • A modal dialog containing a combobox: the input owns aria-activedescendant, results are options in groups.
  • The number of results is announced politely as you type.
  • Focus is trapped while open and returns to where it was when the palette closes.
  • Hovering only changes the active row when the pointer actually moves, so keyboard navigation under a resting cursor is never hijacked.

Keyboard #

Key Action
⌘KToggle the palette (Ctrl K on Windows and Linux).
↓↑Move through results, wrapping around.
CtrlNNext result.
CtrlPPrevious result.
PageUpPageDownMove five results at a time.
EnterRun the active item.
EscClose and return focus.