pub struct CommandPalette<A = ()> { /* private fields */ }Expand description
A searchable modal command overlay over one optional host child.
Visibility supports controlled, writable-bound, and internal modes. Query state supports writable-bound or internal modes. Escape, blur, outside click, and enabled command activation request close. Controlled visibility requires the consumer to update its binding. Arrow/Home/End navigation wraps/skips disabled items. Space is reserved for activation, so it is not inserted into the query by the keyboard handler.
§Examples
use ailloli_ui_widgets::controls::{CommandItem, CommandPalette};
let palette = CommandPalette::<()>::new()
.item(CommandItem::new("Open file"))
.default_open(true);
let _ = palette;Implementations§
Source§impl<A: 'static> CommandPalette<A>
impl<A: 'static> CommandPalette<A>
Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets preferred height from a logical-pixel or length value.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().height(40.0);
let _ = widget;Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets the minimum width bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().min_width(40.0);
let _ = widget;Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets the maximum width bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().max_width(320.0);
let _ = widget;Sourcepub fn min_height(self, value: impl Into<Length>) -> Self
pub fn min_height(self, value: impl Into<Length>) -> Self
Sets the minimum height bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().min_height(24.0);
let _ = widget;Sourcepub fn max_height(self, value: impl Into<Length>) -> Self
pub fn max_height(self, value: impl Into<Length>) -> Self
Sets the maximum height bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().max_height(240.0);
let _ = widget;Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Sets both preferred axes to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill();
let _ = widget;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Sets preferred width to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill_width();
let _ = widget;Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Sets preferred height to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill_height();
let _ = widget;Sourcepub fn margin(self, value: f32) -> Self
pub fn margin(self, value: f32) -> Self
Sets uniform outer margin in logical pixels.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().margin(8.0);
let _ = widget;Sourcepub fn padding(self, value: f32) -> Self
pub fn padding(self, value: f32) -> Self
Sets uniform inner padding in logical pixels.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().padding(8.0);
let _ = widget;Sourcepub fn flex_grow(self) -> Self
pub fn flex_grow(self) -> Self
Sets flex-grow weight to one.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_grow();
let _ = widget;Sourcepub fn flex_grow_by(self, value: f32) -> Self
pub fn flex_grow_by(self, value: f32) -> Self
Sets a dimensionless flex-grow weight.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_grow_by(2.0);
let _ = widget;Sourcepub fn flex_shrink(self, value: f32) -> Self
pub fn flex_shrink(self, value: f32) -> Self
Sets a dimensionless flex-shrink weight.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_shrink(1.0);
let _ = widget;Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
pub fn flex_basis(self, value: impl Into<Length>) -> Self
Sets the preferred main-axis flex basis.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_basis(80.0);
let _ = widget;Sourcepub fn align_self(self, value: AlignItems) -> Self
pub fn align_self(self, value: AlignItems) -> Self
Overrides cross-axis alignment for this flex item.
§Examples
use ailloli_ui_core::style::AlignItems;
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().align_self(AlignItems::Center);
let _ = widget;Source§impl<A: 'static> CommandPalette<A>
impl<A: 'static> CommandPalette<A>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a closed, enabled palette with an empty internal query.
Its default placeholder is "Type a command..."; it has no items or child.
§Examples
use ailloli_ui_widgets::controls::CommandPalette;
let palette: CommandPalette<()> = CommandPalette::new();
let _ = palette;Sourcepub fn open(self, open: impl Into<Binding<bool>>) -> Self
pub fn open(self, open: impl Into<Binding<bool>>) -> Self
Sets controlled static or reactive visibility and clears bound mode.
Close paths reset active selection but cannot mutate this source.
§Examples
use ailloli_ui_widgets::controls::CommandPalette;
let palette: CommandPalette<()> = CommandPalette::new().open(true);
let _ = palette;Sourcepub fn bind_open(self, open: impl Into<Signal<bool>>) -> Self
pub fn bind_open(self, open: impl Into<Signal<bool>>) -> Self
Installs a writable signal for two-way close behavior.
§Examples
use std::{cell::RefCell, rc::Rc};
use ailloli_ui_runtime::component::Signal;
use ailloli_ui_widgets::controls::CommandPalette;
let open = Signal::new(Rc::new(RefCell::new(true)), Rc::new(|| {}));
let palette: CommandPalette<()> = CommandPalette::new().bind_open(open);
let _ = palette;Sourcepub fn default_open(self, open: bool) -> Self
pub fn default_open(self, open: bool) -> Self
Sets initial internal visibility when no external source exists.
It initializes retained state on first build rather than acting as a recurring reopen command.
§Examples
use ailloli_ui_widgets::controls::CommandPalette;
let palette: CommandPalette<()> = CommandPalette::new().default_open(true);
let _ = palette;Sourcepub fn bind_query(self, query: impl Into<Signal<String>>) -> Self
pub fn bind_query(self, query: impl Into<Signal<String>>) -> Self
Installs the writable signal edited by text and IME events.
The current value initializes the persistent text buffer/caret on first
build and overrides Self::default_query.
§Examples
use std::{cell::RefCell, rc::Rc};
use ailloli_ui_runtime::component::Signal;
use ailloli_ui_widgets::controls::CommandPalette;
let query = Signal::new(Rc::new(RefCell::new("open".to_string())), Rc::new(|| {}));
let palette: CommandPalette<()> = CommandPalette::new().bind_query(query);
let _ = palette;Sourcepub fn default_query(self, query: impl Into<String>) -> Self
pub fn default_query(self, query: impl Into<String>) -> Self
Sets the initial internal query used when no query signal is bound.
§Examples
use ailloli_ui_widgets::controls::CommandPalette;
let palette: CommandPalette<()> = CommandPalette::new().default_query("file");
let _ = palette;Sourcepub fn placeholder(self, placeholder: impl Into<Binding<String>>) -> Self
pub fn placeholder(self, placeholder: impl Into<Binding<String>>) -> Self
Sets static or reactive query placeholder text.
Empty placeholder is valid and paints no glyphs.
§Examples
use ailloli_ui_widgets::controls::CommandPalette;
let palette: CommandPalette<()> = CommandPalette::new().placeholder("Search commands");
let _ = palette;Sourcepub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
Sets static or reactive disabled state.
Disabled state hides overlay/hit bounds and removes focus/input role without closing or clearing query/open state.
§Examples
use ailloli_ui_widgets::controls::CommandPalette;
let palette: CommandPalette<()> = CommandPalette::new().open(true).disabled(true);
let _ = palette;Sourcepub fn item(self, item: CommandItem<A>) -> Self
pub fn item(self, item: CommandItem<A>) -> Self
Appends one command in filter/display order.
§Examples
use ailloli_ui_widgets::controls::{CommandItem, CommandPalette};
let palette = CommandPalette::<()>::new().item(CommandItem::new("Open"));
let _ = palette;Sourcepub fn command_style(self, style: CommandPaletteStyle) -> Self
pub fn command_style(self, style: CommandPaletteStyle) -> Self
Replaces complete palette style and geometry.
Callers should keep row_height positive for hit testing and scrolling.
§Examples
use ailloli_ui_core::Theme;
use ailloli_ui_widgets::controls::{CommandPalette, CommandPaletteSize, CommandPaletteStyle};
let style = CommandPaletteStyle::from_theme(Theme::dark(), CommandPaletteSize::Compact);
let palette: CommandPalette<()> = CommandPalette::new().command_style(style);
let _ = palette;Sourcepub fn command_size(self, size: CommandPaletteSize) -> Self
pub fn command_size(self, size: CommandPaletteSize) -> Self
Replaces complete style with the default-theme built-in size.
§Examples
use ailloli_ui_widgets::controls::{CommandPalette, CommandPaletteSize};
let palette: CommandPalette<()> =
CommandPalette::new().command_size(CommandPaletteSize::Compact);
let _ = palette;Sourcepub fn child(self, child: impl IntoView<A>) -> Self
pub fn child(self, child: impl IntoView<A>) -> Self
Sets the sole underlying host child, replacing any previous child.
§Examples
use ailloli_ui_widgets::controls::CommandPalette;
use ailloli_ui_widgets::text::Text;
let palette = CommandPalette::<()>::new().child(Text::new("Workspace"));
let _ = palette;