Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
marimo
Light Logo Dark Logo
  • Getting Started
  • Guides
    • Overview
    • Reactivity
    • Interactivity
    • SQL
    • Run as an app
    • Run as a script
    • Outputs
    • Dataframes
    • Plotting
    • Editor features
      • Editor overview
      • Package management
      • AI completion
      • Hotkeys
    • Theming
    • Best practices
      • Performance
    • Coming from Jupyter
    • Integrating with marimo
      • Richly display objects
      • Custom UI elements
    • Reactive state
    • Online playground
    • Exporting
    • Deploying
  • Recipes
  • API Reference
    • Markdown
    • Inputs
      • Array
      • Batch
      • Button
      • Checkbox
      • Code Editor
      • Dataframe
      • Data Explorer
      • Dates
      • Dictionary
      • Dropdown
      • File
      • File Browser
      • Form
      • Microphone
      • Multiselect
      • Number
      • Radio
      • Range Slider
      • Refresh
      • Run Button
      • Slider
      • Switch
      • Table
      • Tabs
      • Text
      • Text Area
      • Custom UI elements
    • Layouts
      • Accordion
      • Carousel
      • Callout
      • Justify
      • Lazy
      • Plain
      • Routes
      • Sidebar
      • Stacks
      • Tree
    • Plotting
    • Media
      • Image
      • Audio
      • Video
      • PDF
      • Download Media
      • Plain text
    • Diagrams
    • Status
    • Outputs
    • Control flow
    • HTML
    • Query Parameters
    • Command Line Arguments
    • State
    • App
    • Cell
    • Miscellaneous
  • FAQ
  • Examples
  • Integrations
    • Google Cloud Storage
    • Google Cloud BigQuery
    • Google Sheets
  • Community

Links

  • GitHub
  • Discord
  • Newsletter
  • Twitter
  • Marimo Cloud Waitlist
  • Blog
Back to top
View this page
Edit this page

Dropdown¶

class marimo.ui.dropdown(options: Sequence[str] | dict[str, Any], value: str | None = None, allow_select_none: bool | None = None, *, label: str = '', on_change: Callable[[Any], None] | None = None, full_width: bool = False)¶

A dropdown menu.

Example.

dropdown = mo.ui.dropdown(
    options=["a", "b", "c"], value="a", label="choose one"
)
dropdown = mo.ui.dropdown(
    options={"one": 1, "two": 2, "three": 3},
    value="one",
    label="pick a number",
)

Or from a dataframe series:

dropdown = mo.ui.dropdown.from_series(df["column_name"])

Attributes.

  • value: the selected value, or None if no selection

  • options: a dict mapping option name to option value

  • selected_key: the selected option’s key, or None if no selection

Initialization Args.

  • options: sequence of text options, or dict mapping option name to option value

  • value: default option name

  • allow_select_none: whether to include special option ("--") for a None value; when None, defaults to True when value is None

  • label: text label for the element

  • on_change: optional callback to run when this element’s value changes

  • full_width: whether the input should take up the full width of its container

Public methods

from_series(series, **kwargs)

Create a dropdown from a dataframe series.

Inherited from UIElement

form([label, bordered, loading, ...])

Create a submittable form out of this UIElement.

send_message(message, buffers)

Send a message to the element rendered on the frontend from the backend.

Inherited from Html

batch(**elements)

Convert an HTML object with templated text into a UI element.

center()

Center an item.

right()

Right-justify.

left()

Left-justify.

callout([kind])

Create a callout containing this HTML element.

style(style)

Wrap an object in a styled container.

Public Data Attributes:

selected_key

The selected option’s key, or None if no selection.

Inherited from UIElement

value

The element’s current value.

Inherited from Html

text

A string of HTML representing this element.


static from_series(series: DataFrameSeries, **kwargs: Any) → dropdown¶

Create a dropdown from a dataframe series.

property selected_key: str | None¶

The selected option’s key, or None if no selection.

Next
File
Previous
Dictionary
Copyright © 2024, marimo-team
Made with Sphinx and @pradyunsg's Furo
On this page
  • Dropdown
    • dropdown
      • dropdown.from_series()
      • dropdown.selected_key