Autocomplete
Filters suggestions for free-form text without requiring a selected value.
#Import
Import Autocomplete from quickgui.
use quickgui::*;#Usage
let mut state = AutocompleteState::new(items);
state.set_query("qui");
div().child(text(state.query()))#Anatomy
Autocomplete::rootAutocomplete::inputAutocomplete::option_partAutocomplete::labelAutocomplete::valueAutocomplete::iconAutocomplete::input_groupAutocomplete::clearAutocomplete::portalAutocomplete::positionerAutocomplete::popupAutocomplete::arrowAutocomplete::statusAutocomplete::emptyAutocomplete::listAutocomplete::itemAutocomplete::item_indicatorAutocomplete::groupAutocomplete::group_labelAutocomplete::collectionAutocomplete::separator
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
AutocompleteState
View sourcepub fn new(items: impl IntoIterator<Item = PickerItem<T>>) -> Result<Self, PickerError>with_layoutpub fn with_layout(mut self, layout: AutocompletePopoverLayout) -> Self—
Configures with layout for this part.
pub fn with_layout(mut self, layout: AutocompletePopoverLayout) -> SelfView sourcewith_filter_modepub fn with_filter_mode(mut self, filter_mode: PickerFilterMode) -> Self—
Configures with filter mode for this part.
pub fn with_filter_mode(mut self, filter_mode: PickerFilterMode) -> SelfView sourcewith_filterpub fn with_filter(mut self, filter: PickerFilter) -> Self—
Install an application-supplied filter predicate before a runtime context exists. This is Base UI's `filter` prop. The predicate replaces [`Self::filter_mode`] entirely; [`Self::set_filter`] passing `None` restores it.
pub fn with_filter(mut self, filter: PickerFilter) -> SelfView sourcewith_valuepub fn with_value(mut self, value: impl Into<Arc<str>>) -> Self—
Set the initial free-form value before a runtime context exists. This is the constructor-time equivalent of [`Self::set_value`]: a state that has never been mounted owns no popover to synchronize, so no [`EventContext`] is needed. The value is bounded by [`MAX_AUTOCOMPLETE_VALUE_BYTES`] exactly as it is at runtime.
pub fn with_value(mut self, value: impl Into<Arc<str>>) -> SelfView sourcelayoutpub const fn layout(&self) -> AutocompletePopoverLayout—
set_layoutpub fn set_layout(&mut self, layout: AutocompletePopoverLayout, cx: &mut EventContext) -> bool—
Replace native popover geometry, closing an open fixed-size child first.
pub fn set_layout(&mut self, layout: AutocompletePopoverLayout, cx: &mut EventContext) -> boolView sourceselection_behaviorpub const fn selection_behavior(&self) -> AutocompleteSelectionBehavior—
Configures selection behavior for this part.
pub const fn selection_behavior(&self) -> AutocompleteSelectionBehaviorView sourceset_selection_behaviorpub fn set_selection_behavior(&mut self, behavior: AutocompleteSelectionBehavior) -> bool—
Configures set selection behavior for this part.
pub fn set_selection_behavior(&mut self, behavior: AutocompleteSelectionBehavior) -> boolView sourcevaluepub fn value(&self) -> &Arc<str>—
set_valuepub fn set_value(&mut self, value: impl Into<Arc<str>>, cx: &mut EventContext) -> bool—
Replace the free-form value and recompute or forward the bounded suggestion query.
pub fn set_value(&mut self, value: impl Into<Arc<str>>, cx: &mut EventContext) -> boolView sourceitemspub fn items(&self) -> &[PickerItem<T>]—
set_itemspub fn set_items( &mut self, items: impl IntoIterator<Item = PickerItem<T>>, cx: &mut EventContext, ) -> Result<(), PickerError>—
Atomically replace suggestions and update an open child without reopening its surface.
pub fn set_items( &mut self, items: impl IntoIterator<Item = PickerItem<T>>, cx: &mut EventContext, ) -> Result<(), PickerError>View sourcefilter_modepub const fn filter_mode(&self) -> PickerFilterMode—
set_filter_modepub fn set_filter_mode( &mut self, filter_mode: PickerFilterMode, cx: &mut EventContext, ) -> bool—
Configures set filter mode for this part.
pub fn set_filter_mode( &mut self, filter_mode: PickerFilterMode, cx: &mut EventContext, ) -> boolView sourcefilterpub fn filter(&self) -> Option<&PickerFilter>—
The application-supplied filter predicate, when one is installed.
pub fn filter(&self) -> Option<&PickerFilter>View sourceset_filterpub fn set_filter(&mut self, filter: Option<PickerFilter>, cx: &mut EventContext) -> bool—
Replace the built-in filter policy with an application-supplied predicate. Passing `None` restores [`Self::filter_mode`]. The open suggestion surface, if any, is resynchronized exactly once.
pub fn set_filter(&mut self, filter: Option<PickerFilter>, cx: &mut EventContext) -> boolView sourcepopover_windowpub const fn popover_window(&self) -> Option<WindowHandle>—
Configures popover window for this part.
pub const fn popover_window(&self) -> Option<WindowHandle>View sourceis_openpub const fn is_open(&self) -> bool—
is_disabledpub const fn is_disabled(&self) -> bool—
set_disabledpub fn set_disabled(&mut self, disabled: bool, cx: &mut EventContext) -> bool—
Configures set disabled for this part.
pub fn set_disabled(&mut self, disabled: bool, cx: &mut EventContext) -> boolView sourceis_invalidpub const fn is_invalid(&self) -> bool—
set_invalidpub fn set_invalid(&mut self, invalid: bool) -> bool—
Configures set invalid for this part.
pub fn set_invalid(&mut self, invalid: bool) -> boolView sourcevalidation_messagepub fn validation_message(&self) -> Option<&Arc<str>>—
Configures validation message for this part.
pub fn validation_message(&self) -> Option<&Arc<str>>View sourceset_validation_messagepub fn set_validation_message(&mut self, message: impl Into<Arc<str>>) -> bool—
Configures set validation message for this part.
pub fn set_validation_message(&mut self, message: impl Into<Arc<str>>) -> boolView sourceclear_validation_messagepub fn clear_validation_message(&mut self) -> bool—
Configures clear validation message for this part.
pub fn clear_validation_message(&mut self) -> boolView sourceresult_countpub fn result_count(&self) -> usize—
total_match_countpub fn total_match_count(&self) -> usize—
active_result_indexpub fn active_result_index(&self) -> Option<usize>—
Configures active result index for this part.
pub fn active_result_index(&self) -> Option<usize>View sourceactive_source_indexpub fn active_source_index(&self) -> Option<usize>—
Configures active source index for this part.
pub fn active_source_index(&self) -> Option<usize>View sourceclosepub fn close(&mut self, cx: &mut EventContext) -> bool—
surface_idpub fn surface_id(id: impl Into<ElementId>) -> ElementId—
Configures surface id for this part.
pub fn surface_id(id: impl Into<ElementId>) -> ElementIdView sourceoption_id_for_sourcepub fn option_id_for_source( &self, id: impl Into<ElementId>, source_index: usize, ) -> Option<ElementId>—
Configures option id for source for this part.
pub fn option_id_for_source( &self, id: impl Into<ElementId>, source_index: usize, ) -> Option<ElementId>View sourceAutocompleteState::element
View sourcepub fn element<V, PopoverRoot, RenderOption, ValueChanged, Select>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, label: impl Into<Arc<str>>, access: fn(&mut V) -> &mut AutocompleteState<T>, input: Element, popover_root: PopoverRoot, render_option: RenderOption, value_changed: ValueChanged, select: Select, ) -> Element where V: 'static, T: Clone + 'static, PopoverRoot: Fn(AutocompleteListState) -> Element + Clone + 'static, RenderOption: Fn(&PickerItem<T>, AutocompleteOptionState) -> Element + Clone + 'static, ValueChanged: Fn(&mut V, Arc<str>, &mut EventContext) + Clone + 'static, Select: Fn(&mut V, T, &mut EventContext) + Clone + 'static,Build the complete unstyled interaction from caller-owned input, popover, and row elements.
AutocompleteState::element_with
View sourcepub fn element_with<V, PopoverRoot, RenderOption, ValueChanged, Select>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, label: impl Into<Arc<str>>, access: StateAccessor<V, AutocompleteState<T>>, input: Element, popover_root: PopoverRoot, render_option: RenderOption, value_changed: ValueChanged, select: Select, ) -> Element where V: 'static, T: Clone + 'static, PopoverRoot: Fn(AutocompleteListState) -> Element + Clone + 'static, RenderOption: Fn(&PickerItem<T>, AutocompleteOptionState) -> Element + Clone + 'static, ValueChanged: Fn(&mut V, Arc<str>, &mut EventContext) + Clone + 'static, Select: Fn(&mut V, T, &mut EventContext) + Clone + 'static,Build the autocomplete against a per-instance retained-state accessor. A host that renders many declared autocompletes through one view passes an accessor that captures which [`AutocompleteState`] each registered listener resolves.
