ratatui-command-palette
Experimental command palette state and rendering for Ratatui applications.
This crate is part of ratatui-labs. It consumes ratatui-action metadata, owns palette
interaction state, and emits events for the application to dispatch. APIs are experimental and may
change or disappear.
Usage
Applications pass action specs into PaletteState, render the returned view, and handle emitted
events at their own dispatch boundary.
use ;
use ;
let actions = vec!;
let mut palette = new;
palette.open;
palette.set_query;
let view = palette.view;
assert_eq!;
palette.accept;
let event = palette.move_selection;
let Some = event else ;
assert_eq!;
For crossterm applications, convert key events into palette commands with PaletteKey and keep
application policy, such as whether Esc exits or cancels, at the application boundary.
use ;
use PaletteKey;
let key = new;
assert!;
The palette collects Text, Choice, and Bool inputs inline. Choice and Bool inputs emit
preview events as selection changes; Text inputs use the query line as the input field and invoke
with the typed value when accepted. Use PaletteState::cancel_events when the application needs an
explicit PreviewChanged(None) event before cancellation.
Shortcut labels are presentation data, not action metadata. Keep keybindings in the application or
keymap layer, then pass the active labels through ShortcutLabels when rendering a palette view.
Renderers consume PaletteView snapshots. The crate includes modal, flat overlay, split preview,
fullscreen, and inline dropdown renderers so applications can keep one action model while changing
presentation.
use Buffer;
use Rect;
use ActionSpec;
use ;
let actions = vec!;
let mut palette = new;
palette.open;
let view = palette.view;
let area = new;
let mut buffer = empty;
new.render;
new.render;
Run the interactive examples with:
command-palette -- --renderer accepts modal, flat, split, fullscreen, and inline.
Rendered validation is captured by the repository Betamax tape:
The tapes drive the real examples and write screenshots, terminal state, and GIF artifacts under
target/betamax/. Renderer-specific example tapes live under tapes/renderers/. Set
BETAMAX_JOBS to control default parallelism.