mo.ui.dropdown
Create a dropdown menu for selecting from a list of options.
Signature
mo.ui.dropdown(
options: Sequence[str] | dict[str, Any],
value: str | None = None,
allow_select_none: bool | None = None,
searchable: bool = False,
*,
label: str = "",
on_change: Callable[[Any], None] | None = None,
full_width: bool = False
)
Parameters
options
Sequence[str] | dict[str, Any]
required
List of options or dictionary mapping labels to values
Allow deselecting to have no selection (defaults to True if value is None)
Enable search filtering of options
Markdown label for the dropdown
Whether dropdown takes full width
Examples
import marimo as mo
# Simple dropdown
dropdown = mo.ui.dropdown(
options=["Apple", "Banana", "Cherry"],
value="Apple"
)
dropdown
# Dropdown with value mapping
dropdown = mo.ui.dropdown(
options={
"Small": "sm",
"Medium": "md",
"Large": "lg"
},
label="**Select size:**"
)
mo.md(f"Selected: {dropdown.value}") # Returns "sm", "md", or "lg"
# Searchable dropdown
countries = mo.ui.dropdown(
options=["USA", "UK", "Canada", "Australia", "Germany"],
searchable=True,
label="Country"
)
For multiple selections, use mo.ui.multiselect() instead.