A floating action button represents the primary action in an application.
Developers are required to manually position the floating action button within their page layout, for instance by setting a fixed position via CSS.
A floating action button only contains an icon to indicate its action. For a floating action button that may contain text, refer to the extended floating action button below.
import Material.Fab exposing (fab, fabConfig)
type Msg
= FabClicked
main =
fab { fabConfig | onClick = Just FabClicked }
"favorite"Default floating action button configuration
Floating action button configuration
If you want the floating action button to appear in smaller size, set its mini configuration field to True.
fab { fabConfig | mini = True } "favorite"If you want the floating action button to transition off the screen, set its exited configuration field to True.
fab { fabConfig | exited = True } "favorite"Extended floating action button view function
Default extended floating action button configuration
Extended floating action button configuration
To add an icon to a extended floating action 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.
extendedFab { extendedFabConfig | icon = "favorite" }
"Favorites"extendedFab
{ extendedFabConfig
| icon = "favorite"
, trailingIcon = True
}
"Favorites"If you want the extended floating action button to transition off the screen, set its exited configuration field to True.
extendedFab { extendedFabConfig | exited = True }
"Favorites"
Floating action button view function