Command Palette
The Command Palette component provides a searchable, keyboard-accessible interface for quick actions, navigation, and commands. Similar to VS Code's Command Palette or Spotlight on macOS.
Installation
Add the command palette component to your project:
Usage
Default Command Palette
Command Palette
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Command Palette
Full preview from the registry iframe.
Loading preview...
Custom Placeholder
Command Palette
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Command Palette
Full preview from the registry iframe.
Loading preview...
With Icons
Command Palette
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Command Palette
Full preview from the registry iframe.
Loading preview...
With Sections
Command Palette
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Command Palette
Full preview from the registry iframe.
Loading preview...
With Keyboard Shortcuts
Command Palette
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Command Palette
Full preview from the registry iframe.
Loading preview...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
open |
boolean |
false |
Whether the command palette is open |
placeholder |
string |
'Search commands, files...' |
Placeholder text for the search input |
Keyboard Shortcuts
The command palette includes built-in keyboard shortcuts:
| Shortcut | Action |
|---|---|
⌘K / Ctrl+K |
Open the command palette |
Escape |
Close the command palette |
↑ / ↓ |
Navigate through items |
Enter |
Select focused item |
Examples
Basic Usage
<x-ui.command-palette :open="true">
<ul class="p-2">
<li class="hover:bg-muted rounded-md px-3 py-2 text-sm">
Command 1
</li>
<li class="hover:bg-muted rounded-md px-3 py-2 text-sm">
Command 2
</li>
</ul>
</x-ui.command-palette>
With Custom Placeholder
<x-ui.command-palette
:open="true"
placeholder="Search components..."
>
<ul class="p-2">
<li>Button</li>
<li>Alert</li>
</ul>
</x-ui.command-palette>
Controlled with Alpine.js
<div x-data="{ open: false }">
<button @click="open = true">Open (⌘K)</button>
<x-ui.command-palette :open="open">
<ul class="p-2">
<li>Command 1</li>
<li>Command 2</li>
</ul>
</x-ui.command-palette>
</div>
With Livewire Integration
<div x-data="{ open: @entangle($open) }">
<button @click="open = true">Toggle Palette</button>
<x-ui.command-palette :open="open">
<ul class="p-2">
<li wire:click="handleAction('settings')">
Settings
</li>
<li wire:click="handleAction('logout')">
Logout
</li>
</ul>
</x-ui.command-palette>
</div>
Accessibility
The Command Palette component includes proper ARIA attributes and keyboard support:
- Role: Dialog with
aria-modal="true" - Focus Management: Auto-focuses search input when opened
- Keyboard Navigation: Full keyboard support for navigation and selection
- Escape Key: Closes the palette
- Screen Reader: Proper labels and roles for assistive technologies
Notes
- The component uses Alpine.js for state management and interactivity
- The
openprop controls the visibility - usex-dataor@entanglefor dynamic control - The footer shows helpful keyboard shortcuts by default
- Items can contain any content including icons, descriptions, and keyboard shortcuts
- Maximum height of results area is
320pxwith scroll overflow
Next Steps
- Explore Dialog component
- Learn about Dropdown component
- View Input component