Top App Bar acts as a container for items such as application title, navigation icon, and action items.
import Material.TopAppBar as TopAppBar
exposing
( topAppBar
, topAppBarConfig
)
main =
topAppBar topAppBarConfig
[ TopAppBar.row []
[ TopAppBar.section [ TopAppBar.alignStart ]
[ iconButton
{ iconButtonConfig
| additionalAttributes =
[ TopAppBar.navigationIcon ]
}
"menu"
, Html.span [ TopAppBar.title ]
[ text "Title" ]
]
]
]Usually a top app bar contains one row with at least one start-aligned section. This is where you would normally place your navigation icon and title.
Default configuration of a top app bar
Configuration of a top app bar
A row is the first child of a top app bar. It contains the top app bar's
sections.
Sections subdivide the top app bar's rows. A section may be start- or end-aligned. Usually, the first section is start-aligned and contains the top app bar's navigation icon and title.
End-align a top app bar's section
Start-align a top app bar's section
Apply this attribute to a element to mark it as the top app bar's title
A top app bar can contain action items that are placed on the opposite side of
the navigation icon. To do so, add another end-aligned section to the top app
bar's row. Do not forget to set the actionItem attribute on the icons.
topAppBar topAppBarConfig
[ TopAppBar.row []
[ TopAppBar.section [ TopAppBar.alignStart ]
[ iconButton
{ iconButtonConfig
| additionalAttributes =
[ TopAppBar.navigationIcon ]
}
"menu"
, Html.span [ TopAppBar.title ]
[ text "Title" ]
]
, TopAppBar.section [ TopAppBar.alignEnd ]
[ iconButton
{ iconButtonConfig
| additionalAttributes =
[ TopAppBar.actionItem ]
}
"print"
, iconButton
{ iconButtonConfig
| additionalAttributes =
[ TopAppBar.actionItem ]
}
"bookmark"
]
]
]Apply this attribute to a icon button to mark it as a top app bar's action item
To make a top app bar fixed to the top, set its fixed configuration field to
True. Since a fixed top app bar would overlay the pages content, an
appropriate margin has to be applied to the page's content.
topAppBar { topAppBarConfig | fixed = True } []Appropriate padding for a fixed top app bar.
Apply this to the page's content so that a fixed top app bar does not overlay the content.
Appropriate padding for a dense fixed top app bar.
Apply this to the page's content so that a fixed top app bar does not overlay the content.
Appropriate padding for a dense prominent fixed top app bar.
Apply this to the page's content so that a fixed top app bar does not overlay the content.
Appropriate padding for a prominent fixed top app bar.
Apply this to the page's content so that a fixed top app bar does not overlay the content.
Appropriate padding for a short fixed top app bar.
Apply this to the page's content so that a fixed top app bar does not overlay the content.
Short top app bars collapse to the navigation icon side when scrolled.
shortTopAppBar topAppBarConfig []Short top app bar view function
A short top app bar can be configured to always appear closed.
shortCollapsedtopAppBar topAppBarConfig []Short always closed top app bar view function
To make a top app bar taller than the default, you may use a prominent top app bar.
prominentTopAppBar topAppBarConfig []Prominent top app bar view function
To make a top app bar shorter than the default, set its dense configuration
field to True.
topAppBar { topAppBarConfig | dense = True }
Top app bar view function