AutoSuggestBox
A Fluent auto-suggest box: a text box that lists matching suggestions as the user types.
Suggestions whose label contains the typed text, ignoring case, are shown.
Example:
fluent.AutoSuggestBox(
placeholder="Search fruit",
items=[
fluent.AutoSuggestBoxItem(value="apple", label="Apple"),
fluent.AutoSuggestBoxItem(value="banana", label="Banana"),
fluent.AutoSuggestBoxItem(value="cherry", label="Cherry"),
],
)

Inherits: LayoutControl
Properties
autofocus- Whether this box should be focused on initial display.clear_button- Whether a button to clear the box is shown while it has focus and text.error_text- An error message shown in red below the box, which also gets a red underline.items- The suggestions.max_popup_height- The maximum height of the list of suggestions.placeholder- The hint shown while the box is empty.prefix- An icon or control shown before the text.value- The text in the box.
Events
Example
Fluent AutoSuggestBox
import flet_fluent_ui as fluent
import flet as ft
CITIES = ["Amsterdam", "Athens", "Berlin", "Lisbon", "London", "Madrid", "Paris"]
def main(page: ft.Page):
page.title = "Fluent AutoSuggestBox"
def handle_select(e: ft.Event[fluent.AutoSuggestBox]):
status.value = f"Destination: {e.data}"
status = ft.Text("Where to?")
page.add(
ft.SafeArea(
content=ft.Column(
width=300,
controls=[
fluent.AutoSuggestBox(
key="city",
placeholder="Search a city",
prefix=fluent.FluentIcons.SEARCH,
on_select=handle_select,
items=[
fluent.AutoSuggestBoxItem(value=city) for city in CITIES
],
),
status,
],
)
)
)
if __name__ == "__main__":
ft.run(main)

Properties
autofocusclass-attributeinstance-attribute
autofocus: bool = FalseWhether this box should be focused on initial display.
clear_buttonclass-attributeinstance-attribute
clear_button: bool = TrueWhether a button to clear the box is shown while it has focus and text.
error_textclass-attributeinstance-attribute
error_text: str | None = NoneAn error message shown in red below the box, which also gets a red underline.
Set it to tell the user that the value is not valid, and set it to None
to hide it.
itemsclass-attributeinstance-attribute
items: list[AutoSuggestBoxItem] = field(
default_factory=list
)The suggestions.
max_popup_heightclass-attributeinstance-attribute
max_popup_height: Number = 380The maximum height of the list of suggestions.
placeholderclass-attributeinstance-attribute
placeholder: str | None = NoneThe hint shown while the box is empty.
prefixclass-attributeinstance-attribute
prefix: IconDataOrControl | None = NoneAn icon or control shown before the text.
Events
on_changeclass-attributeinstance-attribute
on_change: ControlEventHandler[AutoSuggestBox] | None = (
None
)Called when the text changes, by typing, choosing a suggestion or clearing.
The data property of the event handler argument
contains the new text.
on_selectclass-attributeinstance-attribute
on_select: ControlEventHandler[AutoSuggestBox] | None = (
None
)Called when the user chooses a suggestion.
The data property of the event handler argument
contains the value of the
chosen suggestion.