pub struct ComboBox<T, A = ()> { /* private fields */ }Expand description
Editable, filtered single-selection control over typed values.
Selecting an enabled option updates a signal installed by Self::bind and
invokes the change callback only when its value differs from the current one.
Self::selected is read-only configuration and is not mutated internally.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().option(1, "One").selected(1);
let _ = combo;Implementations§
Source§impl<T: Clone + PartialEq + 'static, A: 'static> ComboBox<T, A>
impl<T: Clone + PartialEq + 'static, A: 'static> ComboBox<T, A>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an enabled empty combo box with Search... placeholder.
It has no selection, no callback, an empty initial query, and a closed default popup.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<&'static str> = ComboBox::new();
let _ = combo;Sourcepub fn placeholder(self, placeholder: impl Into<Binding<String>>) -> Self
pub fn placeholder(self, placeholder: impl Into<Binding<String>>) -> Self
Replaces the static or reactive empty-query placeholder.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().placeholder("Choose...");
let _ = combo;Sourcepub fn option(self, value: T, label: impl Into<String>) -> Self
pub fn option(self, value: T, label: impl Into<String>) -> Self
Appends an enabled, iconless option.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().option(1, "One").option(2, "Two");
let _ = combo;Sourcepub fn combo_option(self, option: ComboBoxOption<T>) -> Self
pub fn combo_option(self, option: ComboBoxOption<T>) -> Self
Appends a fully configured option.
§Examples
use ailloli_ui_widgets::controls::{ComboBox, ComboBoxOption};
let combo: ComboBox<i32> = ComboBox::new()
.combo_option(ComboBoxOption::new(1, "One").disabled(true));
let _ = combo;Sourcepub fn selected(self, selected: impl Into<Binding<T>>) -> Self
pub fn selected(self, selected: impl Into<Binding<T>>) -> Self
Sets a read-only static or reactive selection and clears writable binding.
Activating another option can still emit on_change, but cannot mutate
this selection. If duplicate values exist, the first equal option labels it.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().option(1, "One").selected(1);
let _ = combo;Sourcepub fn bind(self, selected: impl Into<Signal<T>>) -> Self
pub fn bind(self, selected: impl Into<Signal<T>>) -> Self
Binds a writable selection signal.
Activating a different enabled option writes the signal before invoking the change callback.
§Examples
use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::controls::ComboBox;
let selected = State::new(1);
let combo: ComboBox<i32> = ComboBox::new().option(1, "One").bind(selected);
let _ = combo;Sourcepub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
Sets the static or reactive whole-control disabled state.
Disabled combo boxes are not focusable, ignore events, and close an open popup during layout.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().disabled(true);
let _ = combo;Sourcepub fn disabled_signal(self, disabled: Memo<bool>) -> Self
pub fn disabled_signal(self, disabled: Memo<bool>) -> Self
Uses a memo as the reactive whole-control disabled binding.
§Examples
use ailloli_ui_runtime::component::Memo;
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().disabled_signal(Memo::new(|| false));
let _ = combo;Sourcepub fn default_query(self, query: impl Into<String>) -> Self
pub fn default_query(self, query: impl Into<String>) -> Self
Sets the initial editable query, stored unchanged.
An empty value derives the initial query from the selected option label; a nonempty value takes precedence. Filtering trims and ASCII-lowercases it.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().option(1, "Apple").default_query("app");
let _ = combo;Sourcepub fn default_open(self, open: bool) -> Self
pub fn default_open(self, open: bool) -> Self
Sets only the popup’s initial open state.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().default_open(true);
let _ = combo;Sourcepub fn combo_style(self, style: ComboBoxStyle) -> Self
pub fn combo_style(self, style: ComboBoxStyle) -> Self
Replaces the input and popup style without altering explicit layout values.
§Examples
use ailloli_ui_widgets::controls::{ComboBox, ComboBoxStyle};
let combo: ComboBox<i32> = ComboBox::new().combo_style(ComboBoxStyle::default());
let _ = combo;Sourcepub fn combo_size(self, size: ComboBoxSize) -> Self
pub fn combo_size(self, size: ComboBoxSize) -> Self
Re-derives the style from the default theme and requested density.
This overwrites every prior style customization.
§Examples
use ailloli_ui_widgets::controls::{ComboBox, ComboBoxSize};
let combo: ComboBox<i32> = ComboBox::new().combo_size(ComboBoxSize::Compact);
let _ = combo;Sourcepub fn on_change(self, f: impl Fn(T) -> A + 'static) -> Self
pub fn on_change(self, f: impl Fn(T) -> A + 'static) -> Self
Dispatches the application action returned for a changed selection.
Reselecting an equal value, selecting a disabled row, or activating an out-of-range row emits nothing.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32, i32> = ComboBox::new().on_change(|value| value);
let _ = combo;Sourcepub fn on_change_ctx(self, f: impl Fn(&mut EventCtx<A>, T) + 'static) -> Self
pub fn on_change_ctx(self, f: impl Fn(&mut EventCtx<A>, T) + 'static) -> Self
Handles a changed selection with direct event-context access.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().on_change_ctx(|_ctx, _value| {});
let _ = combo;Sourcepub fn width(self, value: impl Into<Length>) -> Self
pub fn width(self, value: impl Into<Length>) -> Self
Sets the trigger layout width in logical pixels or another [Length].
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().width(240.0);
let _ = combo;Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets the trigger layout height in logical pixels or another [Length].
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().height(40.0);
let _ = combo;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Makes the trigger fill its available horizontal layout space.
§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().fill_width();
let _ = combo;