Get help from the marimo community

Updated 4 months ago

Searchable drop-down?

At a glance

The community member has a UI element, person_selection, that is a dropdown with options from a DataFrame df. They are looking for a better way to handle this for large numbers of people, as the DataFrame has thousands of unique records. The community member suggests that they should be able to type a first or last name into a mini search box and have the options appear.

In the comments, another community member suggests using mo.ui.multiselect, which allows typing into the input. The original community member confirms that this works great, and asks if there is a way to enforce at most one selection. Another community member responds that there is a max_selections parameter for this.

There is no explicitly marked answer, but the community members have found a solution using mo.ui.multiselect with the max_selections parameter to handle the large number of people in the DataFrame.

Useful resources
Hi everyone, I have the following ui element:
Plain Text
person_selection = mo.ui.dropdown(
    options=dict(df.select(['name_full', 'person_id']).iter_rows()),
    value="John Smith",
)

The selection is used to show plots related to the person selected from the menu. Is there a better way to do this for large numbers of people? df has thousands of unique records. It feels like I should be able to type a first or a last name into some mini search box and have those options appear. Thank you for your time!
A
S
5 comments
Yea -- can you try mo.ui.multiselect? That lets you type into it: https://docs.marimo.io/api/inputs/multiselect.html#marimo.ui.multiselect
Awesome, this works great. Is there some way to enforce at most one selection is chosen?
Yea, there’s a max_selections param
Described on the doc page i think
Perfect thank you!
Add a reply
Sign up and join the conversation on Discord