Select provides a single-option select menus.
This module concerns the container select. If you are looking for information about select options, refer to Material.Select.Option.
import Material.Select as Select
import Material.Select.Option as SelectOption
type Msg
= ValueChanged String
main =
Select.filled
(Select.config
|> Select.setLabel (Just "Fruit")
|> Select.setValue (Just "")
|> Select.setOnChange ValueChanged
)
[ SelectOption.selectOption
(SelectOption.config |> SelectOption.setValue (Just ""))
[ text "" ]
, SelectOption.selectOption
(SelectOption.config
|> SelectOption.setValue (Just "Apple")
)
[ text "Apple" ]
]Specify a message when the user changes the select
Specify a select to be disabled
Disabled selects cannot be interacted with an have no visual interaction effect.
Specify whether a select is required
Specify additional attributes
Instead of a filled select, you may choose a select with a outline by using the
outlined view function.
Select.outlined Select.config
[ SelectOption.selectOption
(SelectOption.config
|> SelectOption.setValue (Just "")
)
[ text "" ]
]To disable a select, set its setDisabled configuration option to True.
Select.filled (Select.config |> Select.setDisabled True) []To mark a select as required, set its setRequired configuration option to
True.
Select.filled (Select.config |> Select.setRequired True) []TODO(select-with-helper-text)
TODO(select-with-leading-icon)
You may programatically focus a select by assigning an id attribute to it and
use Browser.Dom.focus.
Select.filled
(Select.config
|> Select.setAttributes
[ Html.Attributes.id "my-select" ]
)
[]
Configuration of a select