Skip to main content

CommandBar Component

The CommandBar component provides a powerful command palette interface with keyboard navigation, hotkey support, and customizable styling. It features intelligent search filtering, priority-based sorting, and support for both regular and fixed bottom groups.

Features

  • Keyboard Navigation: Full arrow key navigation and Enter to select
  • Hotkey Support: Register activation events for individual commands
  • Intelligent Search: Custom search functions with priority scoring
  • Color Variants: Multiple color schemes for visual categorization
  • Fixed Bottom Group: Persistent commands that stay visible during scrolling
  • Cedar Editor Integration: Uses Cedar’s rich text editor for input
  • Context Badges: Shows selected context with the integrated ContextBadgeRow
  • Spell System: Automatic hotkey registration using Cedar’s spell system

Import

Basic Usage

Advanced Usage

With Color Variants and Priority Scoring

With Controlled Collapse State

Props

CommandBarProps

boolean
required
Whether the command bar is visible
CommandBarContents
required
Command bar contents organized into groups
string
default:"Type a command or search..."
Placeholder text for the search input
string
Additional CSS classes for the container
() => void
Callback when the command bar should close
boolean
Whether the command bar is in collapsed state (only shows search bar)
(searchText: string) => void
Callback when search text changes

CommandBarItem

string
required
Unique identifier for the item
string
required
Display text for the item
() => void
required
Callback when item is selected
string
Optional description text shown below the label
React.ReactNode
Optional icon (emoji string or React component)
ActivationEvent
Optional hotkey for triggering this command
ActivationMode
default:"TRIGGER"
How the hotkey should behave (TRIGGER, HOLD, TOGGLE)
boolean
default:"false"
Whether the item is disabled
string
Color variant for styling (‘blue’, ‘green’, ‘purple’, ‘orange’, ‘pink’, ‘amber’, ‘red’, ‘indigo’, ‘white’)
(searchText: string, item: CommandBarItem) => boolean
Custom function to determine if item matches search text
(searchText: string, item: CommandBarItem) => number
Function to score items for better ordering (higher scores appear first)
boolean
Whether to ignore hotkey when typing in input elements (auto-determined by default)

CommandBarGroup

string
required
Unique identifier for the group
CommandBarItem[]
required
Items in this group
string
Optional heading text for the group

CommandBarContents

CommandBarGroup[]
required
Array of command groups
CommandBarGroup
Optional group that stays at the bottom outside scroll area

Color Variants

The CommandBar supports the following color variants for visual categorization:
  • blue - Blue theme with hover states
  • green - Green theme for success/create actions
  • purple - Purple theme for special features
  • orange - Orange theme for warnings
  • pink - Pink theme for favorites/highlights
  • amber - Amber theme for pending states
  • red - Red theme for destructive actions
  • indigo - Indigo theme for navigation
  • white - Clean white theme

Keyboard Shortcuts

  • ⌘K - Toggle focus between input and command list
  • Escape - Unfocus input or close command bar
  • Arrow Keys - Navigate through commands
  • Enter - Execute selected command
  • Tab - Focus the search input

Integration with Cedar

The CommandBar automatically integrates with Cedar’s spell system to register hotkeys and uses the Cedar editor for rich text input with context support.

Spell Registration

Each CommandBarItem with an activationEvent automatically registers a spell that:
  • Respects the activationMode setting
  • Only triggers when the command bar is open
  • Automatically closes the command bar after execution
  • Handles input element detection based on modifier keys

Context Integration

The integrated ContextBadgeRow shows selected context from Cedar’s agent input context system, allowing users to see and manage their current context selection.

Examples

File Manager Command Bar

Search-Focused Command Bar

Styling

The CommandBar uses Tailwind CSS classes and supports dark mode. Color variants are implemented using opacity-based backgrounds that work well in both light and dark themes. Custom styling can be applied through the className prop or by overriding the default Tailwind classes.