Navigator
Navigator is a stack of screens: any screen can open another on top of it, and Back returns to the one below.
<Navigator root={<NavigatorScreen title="Settings">…</NavigatorScreen>} screen={(v) => <NavigatorScreen title={v}>…</NavigatorScreen>}/>Use a Navigator when people go deeper into something and come back, such as from settings to notifications to email. It can hold any number of levels. The first screen is the root, and it never closes.
The screens above the root are a list of values that you can control with path and onPathChange. screen turns each value into its screen. Because the path is data, your app can keep it in the URL or open several levels deep at once.
A Navigator has no box of its own, so it is the page system for whatever holds it. In a Shell pane each screen is a Page, with a large title that moves into the pane's header as it scrolls away. In a dialog, a sheet or a titled popover, each screen shows one row with Back, the panel's own title and Close. A popover closes on any press outside it, so keep a flow of several steps in a dialog or a sheet. Don't put a Navigator inside a Page.
Open a screen with a NavigatorLink, or call push from useNavigator. Back closes the top screen and isn't shown on the root. The screens underneath stay open but hidden, so a list keeps its scroll position and a field keeps what you typed.
When a screen opens, focus moves to its title. When you go back, focus returns to the control that opened it. Escape closes whatever holds the Navigator, such as a dialog, and never goes back one screen.
Topics
Every symbol this component exports, grouped by the job it does. Each one carries the props it declares; each one has an anchor of its own.
Holding the screens
Navigator
Navigator is a stack of screens: any screen can open another on top of it, and Back returns to the one below.
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The frame around the screens, when you need your own: a band with actions, and a scroller holding NavigatorOutlet. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
defaultPath? | readonly T[] | The path to start with when the navigator controls its own path. |
labels? | NavigatorLabels | The navigator's own words: Back, Close and the band's name. |
onPathChange? | (path: T[]) => void | Called with the new path whenever a screen opens or closes. |
path? | readonly T[] | The screens above the root, as values. |
root | React.ReactNode | The root screen, usually a NavigatorScreen. |
screen | (value: T) => React.ReactNode | Turns a value from the path into its screen, usually a NavigatorScreen. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
NavigatorScreen
One screen, with its title. In a pane it is a Page, and elsewhere it shows a row with Back and a small heading
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The screen's content, under its title. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
title | string | The screen's title. |
Going deeper and back
NavigatorLink
A row that opens the next screen when pressed. It pushes its value onto the path and shows a chevron
| Prop | Type | What it does |
|---|---|---|
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
current? | boolean | Marks the row as the current location, such as the page you are on or the open file. |
disabled? | boolean | Disables the row. |
highlighted? | boolean | Highlights the row from your code. |
leading? | React.ReactNode | Content before the label, such as an icon, an avatar or a tick. |
render? | RenderElement | Renders the row as a different element. |
size? | "1" | "2" | "3" | "4" | Sets the height of the row. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
tone? | "neutral" | "accent" | "destructive" | "blue" | "green" | "orange" | "amber" | "pink" | "purple" | "success" | "warning" | "info" | Sets the colour family of the row. |
value | T | The value pushed onto the path when the row is pressed. |
It also takes every prop of a <button>.
- A Navigator inside a Page — A Navigator is the page system for its region, so inside a Page it would put a second page title on the screen. Put the Navigator in a dialog or a sheet instead.
- A Navigator inside another Navigator in the same region — Two navigators in one region would show two bars with two Back buttons.
- Escape to go back — Escape closes the dialog or sheet that holds the Navigator. Going back is the Back button.
- A disabled Back on the root — There is nowhere to go back to, so the button isn't shown.
- A URL — Kookie has no router. Keep the path in your URL yourself with
pathandonPathChange.