aforemny/material-components-web-elm/4.0.0

NOTE: the latest version is 9.1.0

Material.Chip.Choice

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

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

Table of Contents

Resources

Basic Usage

import Material.Chip.Choice as ChoiceChip
import Material.ChipSet.Choice as ChoiceChipSet


type Color
    = Red
    | Blue


type Msg
    = ColorChanged Color


main =
    ChoiceChipSet.chipSet
        (ChoiceChipSet.config
            { toLabel =
                \color ->
                    case color of
                        Red ->
                            "Red"


                        Blue ->
                            "Blue"
            }
            |> ChoiceChipSet.setSelected (Just Red)
            |> ChocieChipSet.setOnClick ColorChanged
        )
        [ ChoiceChip.chip ChoiceChip.config Red
        , ChoiceChip.chip ChoiceChip.config Blue
        ]

Configuration

type alias Config msg =
Config msg

Configuration of a choice chip

config : Config msg

Default configuration of a choice chip

Configuration Options

setIcon : Maybe String -> Config msg -> Config msg

Specify whether the chip displays an icon

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

Specify additional attributes

Choice Chips

chip : Config msg -> a -> Chip a msg

Choice chip view function

type alias Chip a msg =
Chip a msg

Choice chip type