Icon toggles allow users to take actions, and make choices, with a single tap.
If you are looking for a button that has an icon as well as text, refer to Button.
import Material.IconToggle
exposing
( iconToggle
, iconToggleConfig
)
type Msg
= IconToggleClicked
main =
iconToggle
{ iconToggleConfig
| on = True
, onClick = Just IconToggleClicked
}
{ offIcon = "favorite_outlined"
, onIcon = "favorite"
}Icon toggles are a variant of icon buttons that change their state when clicked.
iconToggle { iconToggleConfig | on = True }
{ offIcon = "favorite_border", onIcon = "favorite" }Default icon toggle configuration
Icon toggle configuration
To set the state of a icon toggle, set its on configuration field to a Bool value. State only applies to the icon toggle variant, icon buttons ignore this configuration field.
iconToggle { iconToggleConfig | on = True }
{ offIcon = "favorite_border", onIcon = "favorite" }To disable a icon toggle, set its disabled configuration field to True. Disabled icon buttons cannot be interacted with and have no visual interaction effect.
iconToggle { iconButtonConfig | disabled = True }
{ offIcon = "favorite_border", onIcon = "favorite" }To set the arial-label attribute of a icon toggle, set its label
configuration field to a String.
iconToggle
{ iconButtonConfig | label = "Add to favorites" }
{ offIcon = "favorite_border", onIcon = "favorite" }
Icon toggle view function