aforemny/material-components-web-elm/3.0.0

NOTE: the latest version is 9.1.0

Material.Select.Option

Select provides a single-option select menus.

This module concerns the select option. If you are looking for information about the container select, refer to Material.Select.

Table of Contents

Resources

Basic Usage

import Material.Select as Select
import Material.Select.Option as SelectOption


type Msg
    = ValueChanged String


main =
    Select.filled
        (Select.config
            |> Select.setLabel "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" ]
        ]

Configuration

type alias Config msg =
Config msg

Configuration of a select option

config : Config msg

Default configuration of a select option

Configuration Options

setValue : Maybe String -> Config msg -> Config msg

Specify a select option's label

setDisabled : Bool -> Config msg -> Config msg

Specify whether a select option is disabled

Disabled select options cannot be selected.

setAttributes : List (Attribute msg) -> Config msg -> Config msg

Specify additional attributes

Select Option

type alias SelectOption msg =
SelectOption msg

Select option type

selectOption : Config msg -> List (Html msg) -> SelectOption msg

Select option constructor

Disabled Select Option

To disable one select's option, set its setDisabled configuration option to True.

SelectOption.selectOption
    (SelectOption.config |> SelectOption.setDisabled True)
    [ text "" ]

This is particularly useful on the first emply option if you have a select that must be filled but is not initially filled.