NavHeader
The bar at the top of a screen: a back button when there is a screen to go back to, the title, and leading and trailing actions.
Stability: experimental
Props
| Prop | Type | Default | Means |
title | string | | The screen's title, its heading. |
large | boolean | false | A big title under the bar, which scrolls away under it while the bar's own title fades in. |
showBack | boolean | true | Show the back button whenever canGoBack() is true. false never shows it. |
onBack | () => void | | Runs instead of back() when the back button is pressed, such as to confirm leaving a draft. |
up | string | | The parent route, such as /profile for /profile/settings. When there is no screen to go back to (the screen was opened from its address), the button goes up to it instead, replacing this screen. |
upTitle | string | | The parent's title, shown on the up button and naming it Up to <upTitle>. |
Pieces
| Piece | Means |
leading | Actions after the back button, at the leading edge. |
trailing | Actions at the trailing edge, such as IconButtons. |
States
| State | Looks like |
with back | A primary chevron and the previous screen's title (or Back), at the leading edge. |
with up | The same chevron with the parent's title (or Up), when there is nothing to go back to and up is given. |
large | A 28px title under the bar; the bar's title and bottom line appear as the screen scrolls past it. |
scrolled | The bar stays at the top of the screen, over the content, with a blurred canvas background. |
Accessibility
| |
| role | banner, holding a heading |
| name | The heading is the title. The back button is named Back, or Back to <previous title> when that screen has a title. |
| focus | The back button and the pieces' controls are in the Tab order. |
| keyboard | Enter and Space press the back button. |
| notes | An up button, named Up or Up to <upTitle>, shows instead when canGoBack() is false and up is given. The back button shows only when canGoBack() from @duolith/client is true: the screen was pushed from another one. Not for the first screen of a visit, a screen opened from its address, or one a tab opened. With large, the big title is the heading and the bar's copy is hidden until it fades in. |
Theme tokens
color.canvas color.border color.primary color.ink space.2 space.4 radius.md text.label text.title text.body
Example
<NavHeader title="Inbox" large>
<piece name="trailing"><IconButton icon="edit" label="Compose" /></piece>
</NavHeader>