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.
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)
|> ChoiceChipSet.setOnChange ColorChanged
)
(ChoiceChip.chip ChoiceChip.config Red)
[ ChoiceChip.chip ChoiceChip.config Blue
]Default configuration of a choice chip
Specify whether the chip displays an icon
Specify additional attributes
Choice chip view function
Choice chip type
This library natively supports Material Icons. However, you may also include SVG or custom icons such as FontAwesome.
Icon type
Material Icon
ChoiceChip.chip
(ChoiceChip.config
|> ChoiceChip.setIcon
(Just (ChoiceChip.icon "favorite"))
)
"Add to favorites"Custom icon
ChoiceChip.chip
(ChoiceChip.config
|> ChoiceChip.setIcon
(Just
(ChoiceChip.customIcon Html.i
[ class "fab fa-font-awesome" ]
[]
)
)
)
"Font awesome"SVG icon
ChoiceChip.chip
(ChoiceChip.config
|> ChoiceChip.setIcon
(Just
(ChoiceChip.svgIcon
[ Svg.Attributes.viewBox "…" ]
[-- …
]
)
)
)
"Font awesome"
Configuration of a choice chip