marimo
marimo copied to clipboard
Allow custom user input values in mo.ui.dropdown
Description
Currently, mo.ui.dropdown only allows users to select from predefined options.
In some workflows, it would be useful for users to input a new value directly into the dropdown field, for example, entering a new label or category that isn’t yet part of the available options.
Suggested solution
Add an optional flag, e.g. allow_custom=True, to mo.ui.dropdown which enables users to type a custom value in addition to selecting from the provided options.
This would behave similarly to searchable=True, but instead of restricting input to the provided list, the user's typed value could be accepted and stored in the output variable.
Example usage:
fruit = mo.ui.dropdown(
label="Select or type a fruit",
options=["Apple", "Banana", "Cherry"],
allow_custom=True
)
When a user types "Mango" (not in the options list), the component would return "Mango" as the stored value.
Are you willing to submit a PR?
- [ ] Yes
Alternatives
A possible workaround is combining a mo.ui.text input with a mo.ui.dropdown, but this requires additional logic to sync values and complicates the UI. A native flag in mo.ui.dropdown would be a more elegant and consistent solution.
Additional context
No response
This would be super useful!! - not sure if there is a similar feature request raised
Hey @DBP008 thanks for the feature request. We are open to adding this, but currently prioritizing stability right now so may not get to it ourselves. But we welcome contributions