Skip to main content

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
value
str
Initially selected value
allow_select_none
bool
Allow deselecting to have no selection (defaults to True if value is None)
searchable
bool
default:"False"
Enable search filtering of options
label
str
default:"''"
Markdown label for the dropdown
full_width
bool
default:"False"
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.

Build docs developers (and LLMs) love