Buttons allow users to take actions, and make choices, with a single tap.
import Material.Button exposing (buttonConfig, textButton)
type Msg
= ButtonClicked
main =
textButton
{ buttonConfig | onClick = Just ButtonClicked }
"Text"Default configuration of a button
Configuration of a button
Buttons may appear in different variants. Use textButton or outlinedButton
if you want a button that is flush with the surface, and raisedButton or
unelevatedButton for a button that is contained.
Outlined button variant (flush with outline)
Raised button variant (contained with elevation)
Unelevated button variant (contained without elevation)
To add an icon to a button, set its icon configuration field to the name of a
Material Icon. If you want the icon to be
positioned after the button's label, also set the trailingIcon configuration
field to True.
textButton
{ buttonConfig | icon = Just "favorite" }
"Like"textButton
{ buttonConfig
| icon = Just "favorite"
, trailingIcon = True
}
"Like"To disable a button, set its disabled configuration field to True. Disabled
buttons cannot be interacted with and have no visual interaction effect.
textButton { buttonConfig | disabled = True } "Disabled"To make a button's text and container margins slightly smaller, set the dense
configuration field to True.
textButton { buttonConfig | dense = True } "Dense"
Text button variant (flush without outline)