aforemny/material-components-web-elm/2.0.0

NOTE: the latest version is 9.1.0

Material.Chips

Chips are compact elements that allow users to enter information, select a choice, filter content, or trigger an action.

Table of Contents

Resources

Basic Usage

import Material.Chips
    exposing
        ( choiceChip
        , choiceChipConfig
        , choiceChipSet
        )


type Msg
    = ChipSelected String


main =
    [ choiceChipSet []
        [ choiceChip
            { choiceChipConfig
                | selected = True
                , onClick = Just (ChipSelected "One")
            }
            "Chip One"
        , choiceChip
            { choiceChipConfig
                | onClick = Just (ChipSelected "Two")
            }
            "Chip Two"
        ]
    ]

Choice Chips

Choice chips are a variant of chips which allow single selection from a set of options.

choiceChipSet []
    [ choiceChip
        { choiceChipConfig
            | selected = True
            , onClick = Just (ChipSelected "One")
        }
        "Chip One"
    , choiceChip
        { choiceChipConfig
            | onClick = Just (ChipSelected "Two")
        }
        "Chip Two"
    ]
choiceChipSet : List (Attribute msg) -> List (ChoiceChip msg) -> Html msg

Choice chip container

choiceChip : ChoiceChipConfig msg -> String -> ChoiceChip msg

Choice chip view function

type ChoiceChip msg

Choice Chip type

choiceChipConfig : ChoiceChipConfig msg

Default configuration of a choice chip

type alias ChoiceChipConfig msg =
{ icon : Maybe String
, selected : Bool
, additionalAttributes : List (Attribute msg)
, onClick : Maybe msg
}

Configuration of a choice chip

Filter Chips

Filter chips are a variant of chips which allow multiple selection from a set of options. When a filter chip is selected, a checkmark appears as the leading icon. If the chip already has a leading icon, the checkmark replaces it.

filterChipSet []
    [ filterChip
        { filterChipConfig
            | selected = True
            , onClick = Just (ChipSelected "Chip One")
        }
        "Tops"
    , filterChip
        { filterChipConfig
            | onClick = Just (ChipSelected "Chip Two")
        }
        "Shoes"
    ]
filterChipSet : List (Attribute msg) -> List (FilterChip msg) -> Html msg

Filter chip container

filterChip : FilterChipConfig msg -> String -> FilterChip msg

Filter chip view function

type FilterChip msg

Filter chip type

filterChipConfig : FilterChipConfig msg

Default configuration of a filter chip

type alias FilterChipConfig msg =
{ icon : Maybe String
, selected : Bool
, additionalAttributes : List (Attribute msg)
, onClick : Maybe msg
}

Configuration of a filter chip

Input Chips

Input chips are a variant of chips which enable user input by converting text into chips.

inputChipSet []
    [ inputChip inputChipConfig "Chip One"
    , inputChip inputChipConfig "Chip Two"
    ]
inputChipSet : List (Attribute msg) -> List (InputChip msg) -> Html msg

Input chip container

inputChip : InputChipConfig msg -> String -> InputChip msg

Input chip view function

type InputChip msg

Input chip type

inputChipConfig : InputChipConfig msg

Default configuration of a input chip

type alias InputChipConfig msg =
{ icon : String
, additionalAttributes : List (Attribute msg)
, onClick : Maybe msg
, onTrailingIconClick : Maybe msg
}

Configuration of a input chip