Fusuma

Components / Components

combobox

A text field with a list of suggestions under it: the app filters its options by what was typed and gives the first SUGGESTIONS of them; pressing one sends on_pick(index) (the app puts it in the field and clears the list).

How it looks

Drawn by the toolkit from the example below. No page of the gallery uses combobox yet, so there is nothing to run.

combobox drawn by Fusuma

A text field with a list of suggestions under it: the app filters its options by what was typed and gives the first SUGGESTIONS of them; pressing one sends on_pick(index) (the app puts it in the field and clears the list). The list is part of the page, not a floating menu, so the field keeps the focus while the person types.

Signature

pub fn combobox<'a, M: Clone + 'a>( value: &'a str, placeholder: &'static str, on_input: fn(&str) -> M, suggestions: &'a [&'a str], on_pick: fn(usize) -> M, ) -> impl View<M> + 'a

Example

use fusuma::combobox;
let view = combobox("ru", "City", |_| 0, &["Rust City"], |_| 1);
let built = fusuma::doc::built::<i32, _>(&view);
assert!(built.texts().contains(&"Rust City"));

All components · Source