Dropdown

A dropdown is a list in which the selected item is always visible while other items are visible on demand by clicking a dropdown button. Dropdowns are typically used for forms.

Properties#

NameTypeDefaultDescription
valuestringkey value of the selected option.
labelstringLabel to display above the control.
placeholderstringThe short hint displayed in the dropdown before the user selects a value.
errorMessagestringStatic error message displayed below the dropdown.
datastringAdditional data attached to the control. The value is passed in change event data along with a dropdown selected value.

Events#

NameDescription
changeFires when the value of dropdown is changed.

Child controls#

Option control#

Option represents an item within dropdown list.

NameTypeDefaultDescription
keystringOption's key. text value will be used instead if key is not specified.
textstringOption's display text. key value will be used instead if text is not specified.

Examples#

Adding a new dropdown with a couple of options defined as tuples:

dd1 = page.add(Dropdown(label="Favorite color:", options=[
("r", "Red"),
("g", "Green"),
("b", "Blue")
]))

or as Option controls:

dd1 = page.add(Dropdown(label="Favorite color:", options=[
Option("r", "Red"),
Option("g", "Green"),
Option("b", "Blue")
]))

Get the key of selected option:

favorite_color = page.get_value(dd1)