Browse documentation

Command palette

Search actions from the keyboard and execute the selected command.

Import

Load the optional component layer before using the examples below.

Ruby
require "zaniah/ui"

Commands

Provide label/action pairs or build it from registered application actions.

Rendered example
Command palette with a search field and matching commands.
Rendered by Zaniah's headless backend.
Ruby
commands = [["Open file", ->(*) { puts "Open" }],
            ["Close file", ->(*) { puts "Close" }]]
Zaniah::UI::CommandPalette.new(commands, open: true)

Application actions

from(app.actions) carries action titles, availability, and shortcut labels into the palette.

Ruby
Zaniah::UI::CommandPalette.from(app.actions)

API summary

Constructor options and behaviors are drawn from the component reference.

ComponentConstructor and methodsVariants or behavior
CommandPalette(commands, open:, placeholder:, matcher:); .from(app.actions)searchable modal, Up/Down/Enter

Accessibility

The palette is a dialog with a list. Up and Down move through matches; Enter runs the selected action.

ComponentSemantic role
CommandPalettedialog/list