pub struct Select<T, A = ()> { /* private fields */ }Expand description
Controlled single-selection trigger over typed values.
Selecting an enabled option updates a signal installed by Self::bind and
invokes the 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::Select;
let select: Select<i32> = Select::new().option(1, "One").selected(1);
let _ = select;Implementations§
Source§impl<T: Clone + PartialEq + 'static, A: 'static> Select<T, A>
impl<T: Clone + PartialEq + 'static, A: 'static> Select<T, A>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an enabled empty select with Select option placeholder.
It has no selection or callback, prefers bottom placement, and starts closed.
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<&'static str> = Select::new();
let _ = select;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 no-selection label.
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().placeholder("Choose...");
let _ = select;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::Select;
let select: Select<i32> = Select::new().option(1, "One").option(2, "Two");
let _ = select;Sourcepub fn select_option(self, option: SelectOption<T>) -> Self
pub fn select_option(self, option: SelectOption<T>) -> Self
Appends a fully configured option.
§Examples
use ailloli_ui_widgets::controls::{Select, SelectOption};
let select: Select<i32> = Select::new()
.select_option(SelectOption::new(1, "One").disabled(true));
let _ = select;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 value may emit the callback but cannot mutate this selection. Duplicate values resolve to the first equal option.
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().option(1, "One").selected(1);
let _ = select;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::Select;
let select: Select<i32> = Select::new().option(1, "One").bind(State::new(1));
let _ = select;Sourcepub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
Sets static or reactive whole-control disabled state.
Disabled selects are not focusable, ignore events, and close an open popup during layout.
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().disabled(true);
let _ = select;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::Select;
let select: Select<i32> = Select::new().disabled_signal(Memo::new(|| false));
let _ = select;Sourcepub fn default_open(self, open: bool) -> Self
pub fn default_open(self, open: bool) -> Self
Sets only the retained popup’s initial open state.
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().default_open(true);
let _ = select;Sourcepub fn popup_placement(self, placement: PopupPlacement) -> Self
pub fn popup_placement(self, placement: PopupPlacement) -> Self
Sets the preferred PopupPlacement::Top or PopupPlacement::Bottom side.
Runtime geometry may clamp the resulting rectangle; this builder does not enable automatic side flipping.
§Examples
use ailloli_ui_widgets::controls::{PopupPlacement, Select};
let select: Select<i32> = Select::new().popup_placement(PopupPlacement::Top);
let _ = select;Sourcepub fn select_style(self, style: SelectStyle) -> Self
pub fn select_style(self, style: SelectStyle) -> Self
Replaces trigger and popup style without altering explicit layout values.
§Examples
use ailloli_ui_widgets::controls::{Select, SelectStyle};
let select: Select<i32> = Select::new().select_style(SelectStyle::default());
let _ = select;Sourcepub fn select_size(self, size: SelectSize) -> Self
pub fn select_size(self, size: SelectSize) -> Self
Re-derives style from the default theme and requested density.
This overwrites every previous select-style customization.
§Examples
use ailloli_ui_widgets::controls::{Select, SelectSize};
let select: Select<i32> = Select::new().select_size(SelectSize::Compact);
let _ = select;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.
Equal values, disabled rows, and out-of-range indices emit nothing.
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32, i32> = Select::new().on_change(|value| value);
let _ = select;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::Select;
let select: Select<i32> = Select::new().on_change_ctx(|_ctx, _value| {});
let _ = select;Sourcepub fn width(self, value: impl Into<Length>) -> Self
pub fn width(self, value: impl Into<Length>) -> Self
Sets trigger layout width in logical pixels or another [Length].
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().width(240.0);
let _ = select;Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets trigger layout height in logical pixels or another [Length].
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().height(40.0);
let _ = select;Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets minimum trigger width in logical pixels or another [Length].
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().min_width(120.0);
let _ = select;Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets maximum trigger width in logical pixels or another [Length].
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().max_width(360.0);
let _ = select;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Makes the trigger fill available horizontal layout space.
§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().fill_width();
let _ = select;