abadi199 / elm-input-extra / Dropdown

Dropdown

Options


type alias Item =
{ value : String
, text : String
, enabled : Basics.Bool 
}

Item is the individual content of the dropdown.


type alias Options msg =
{ items : List Item
, emptyItem : Maybe Item
, onChange : Maybe String -> msg 
}

Options for the dropdown.

defaultOptions : (Maybe String -> msg) -> Options msg

Default Options, will give you empty dropdown with no empty item

View

dropdown : Options msg -> List (Html.Attribute msg) -> Maybe String -> Html msg

Html element.

Put this in your view's Html content. Example:

type Msg = DropdownChanged String

Html.div []
    [ Dropdown.dropdown
        (Dropdown.defaultOptions DropdownChanged)
        [ class "my-dropdown" ]
        model.selectedDropdownValue
    ]