Skip to main content

Dropdown

selectors.Dropdown

Creates a Dropdown selector. Selection is limited to a predefined list of options.

ParameterDescriptionDefault
selector_nameThe name of the selector. It must be unique.-
optionsOptions available for this selector.-
options_namesHuman readable counterpart of options. It will be str(options) if not defined.-
labelThe label for the selector. If not passed, the selector shows its selector_name.-
default_valueIf selected option is invalid or not defined, use this value. Must be the option name.-
ignore_user_inputIf passed True, picks default_value instead of the selected value.False
run_on_changeIf passed False the selector will not trigger execution on change.True
placeholderShort hint displayed in the input field before the user enters a value.-
help_textTooltip help message displayed while the input is focused.-
widthCustom selector width.-
isDisableddisable this selector.False
block_uuidOptional value to specify the block that will be executed when the selector triggers execution.(current block uuid)

Examples

sel = selectors.Dropdown("dropdown_0", options=['apple', 'pear'], options_names=['Apple', 'Pear'], label='Select a value')
sel.render()
print("You have selected", sel.value)
from IPython.display import display, HTML
elements =[]

options = ['foo', 'bar', 'zoooo', 'zaaa aa aar']

dropdown = selectors.Dropdown(
'dropdown-1',
options=options,
label='Drowpdown with helptext',
help_text='Custom help message',
)
elements.append(dropdown)

elements_html = "".join(
f'<tr><td>{element}</td><td>{element.value}</td></tr>'
for element in elements
)

display(HTML(f"""
<table>
<td></td><td>clicked</td>
{elements_html}
</table>
"""))

See also

  • MultiDropdown — the multi-selection variant of this control.
  • All selector types — the full catalog of available selector controls.
  • Selectors — common arguments and how to define, render, and read selectors.