Elm UI Dropdown.
Create a new state. You must pass a unique identifier for each dropdown component.
{
...
dropdownState = Dropdown.init "country-dropdown"
}Opaque type for the internal dropdown messages
Opaque type that holds the current config
dropdownConfig =
Dropdown.basic DropdownMsg OptionPicked Element.text Element.textCreate a basic configuration. This takes:
- The message to wrap all the internal messages of the dropdown
- A message to trigger when an item is selected
- A function to get the Element to display from an item, to be used in the select part of the dropdown
- A function to get the Element to display from an item, to be used in the item list of the dropdown
Dropdown.basic DropdownMsg OptionPicked Element.text Element.textCreate a filterable configuration. This takes:
- The message to wrap all the internal messages of the dropdown
- A message to trigger when an item is selected
- A function to get the Element to display from an item, to be used in the select part of the dropdown
- A function to get the Element to display from an item, to be used in the item list of the dropdown
- A function to get the text representation from an item, to be used when filtering elements in the list
Dropdown.basic DropdownMsg OptionPicked Element.text Element.textSets the container visual attributes, default is empty
Dropdown.withContainerAttributes [ width (px 300) ] configSets the content of the Select, default is "-- Select --"
Dropdown.withPromptElement (el [ Font.color (rgb255 123 123 123) ] <| text "Pick one") configSets the select visual attributes, default is empty
Dropdown.withSelectAttributes [ Border.width 1, Border.rounded 5, paddingXY 16 8 ] configSets the search visual attributes, default is empty
Dropdown.withSearchAttributes [ Border.width 0, padding 0 ] configSets the open and close buttons' visual attributes, default is empty
Dropdown.withOpenCloseButtons { openButton = text "+", closeButton = "-" } configSets the item list visual attributes, default is empty
Dropdown.withListAttributes [ Border.width 1, Border.rounded ] configUpdate the component state
DropdownMsg subMsg ->
let
( updated, cmd ) =
Dropdown.update dropdownConfig subMsg model.dropdownState model.items
in
( { model | dropdownState = updated }, cmd )
Opaque type that holds the current state