⌂
›
Reference
›
Dropdown
Dropdown
A material dropdown menu for choosing one value from a list of options. Options are built with dropdown_option.
Example
dropdown(
label: "Fruit",
value: "apple",
options: [
dropdown_option(key: "apple", text: "Apple"),
dropdown_option(key: "banana", text: "Banana"),
dropdown_option(key: "cherry", text: "Cherry")
],
on_change: ->(event) { page.update(status, value: "Picked #{event.control.value}") }
)
Common properties
value— the selected option keyoptions— an array ofdropdown_optionlabelhint_texthelper_texterror_textfilledbgcolorborder/border_color/border_radiuseditable— allow typing into the fieldenable_filter/enable_searchleading_icon/trailing_icon
Options
dropdown_option(key: "us", text: "United States", leading_icon: "flag")
key— the value stored on the dropdowntext— the visible labelcontent— a custom control instead oftextleading_icon/trailing_icondisabled
Usage
Read the choice from control.value:
field = dropdown(
label: "Size",
options: [dropdown_option(key: "s", text: "Small"), dropdown_option(key: "l", text: "Large")]
)
# later:
field.value # => {{{tok_f}}}