A floating action button represents the primary action in an application.
An extended floating action button primarily contains text to indicate its action, and optionally contains an icon. If you are looking for a floating action button that primarily contains an icon, and no text, refer to the regular floating action button.
Developers are required to manually position the floating action button within their page layout, for instance by setting a fixed position via CSS.
import Html.Attributes exposing (style)
import Material.Fab.Extended as ExtendedFab
type Msg
= Clicked
main =
ExtendedFab.fab
(ExtendedFab.config
|> ExtendedFab.setOnClick FabClicked
|> ExtendedFab.setAttributes
[ style "position" "fixed"
, style "bottom" "2rem"
, style "right" "2rem"
]
)
"Favorites"Specify a message when the user clicks the floating action button
Specify whether a floating action button displays an icon
Specify whether a floating action button's icon is a trailing icon
Trailing icons are displyed after the label rather than before.
Specify whether a floating action button transitions off the screen
Specify additional attributes
To add an icon to an extended floating action button, use its setIcon
configuration option and specify the name of a Material
Icon. If you want the icon to be positioned after
the button's label, also set its setTrailingIcon configuration option to
True.
ExtendedFab.fab
(ExtendedFab.config
|> ExtendedFab.setIcon (Just "favorite")
)
"Favorites"ExtendedFab.fab
(ExtendedFab.config
|> ExtendedFab.setIcon (Just "favorite")
|> ExtendedFab.setTrailingIcon True
)
"Favorites"If you want the extended floating action button to transition off the screen,
set its setExited configuration option to True.
ExtendedFab.fab
(ExtendedFab.config |> ExtendedFab.setExited True)
"Favorites"
Extended floating action button configuration