Skip to main content
The Command component provides a searchable command palette that allows users to quickly find and execute actions using keyboard shortcuts or mouse interaction.

Overview

  • Keyboard Shortcuts: Open with CMD+K (Mac) or Ctrl+K (Windows/Linux)
  • Search & Filter: Real-time filtering as you type
  • Keyboard Navigation: Arrow keys to navigate, Enter to execute
  • Customizable: Add your own commands with icons, shortcuts, and categories
  • Accessible: Full keyboard and screen reader support

Basic Usage

Global Keyboard Shortcuts

For app-wide command palette access, wrap your app with HuxCommandShortcuts.wrapper:

Command Item Properties

Shortcut Format

Use Apple symbols for shortcuts without ’+’ signs:
  • Command:
  • Shift:
  • Option:
  • Control:
Examples:
  • ⌘K - Command + K
  • ⌘⇧F - Command + Shift + F
  • ⌘⌥T - Command + Option + T

Customization

Custom Placeholder

Custom Empty State

Command Categories

Organize commands by category for better user experience:

Keyboard Navigation

  • CMD+K / Ctrl+K: Open command palette
  • / : Navigate through commands
  • Enter: Execute selected command
  • Escape: Close command palette
  • Type: Filter commands by name

Examples

File Management Commands

Best Practices

Command Organization: Group related commands by category and use consistent naming conventions.
Shortcut Conflicts: Ensure keyboard shortcuts don’t conflict with system shortcuts or other app shortcuts.
Accessibility: Always provide meaningful labels and descriptions for screen readers.

API Reference

HuxCommand

The main command palette widget.

Constructor

HuxCommandItem

Represents a single command in the palette.

Constructor

HuxCommandShortcuts

Utility class for global keyboard shortcuts.

Methods

  • wrapper() - Wraps your app to provide global shortcuts
  • handleKeyEvent() - Returns a key event handler for custom integration