Duolith docs

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

PropTypeDefaultMeans
titlestringThe screen's title, its heading.
largebooleanfalseA big title under the bar, which scrolls away under it while the bar's own title fades in.
showBackbooleantrueShow the back button whenever canGoBack() is true. false never shows it.
onBack() => voidRuns instead of back() when the back button is pressed, such as to confirm leaving a draft.
upstringThe 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.
upTitlestringThe parent's title, shown on the up button and naming it Up to <upTitle>.

Pieces

PieceMeans
leadingActions after the back button, at the leading edge.
trailingActions at the trailing edge, such as IconButtons.

States

StateLooks like
with backA primary chevron and the previous screen's title (or Back), at the leading edge.
with upThe same chevron with the parent's title (or Up), when there is nothing to go back to and up is given.
largeA 28px title under the bar; the bar's title and bottom line appear as the screen scrolls past it.
scrolledThe bar stays at the top of the screen, over the content, with a blurred canvas background.

Accessibility

rolebanner, holding a heading
nameThe heading is the title. The back button is named Back, or Back to <previous title> when that screen has a title.
focusThe back button and the pieces' controls are in the Tab order.
keyboardEnter and Space press the back button.
notesAn 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>