mostSpecificActive
Of several matching items, the one whose path matches most specifically, so `/forms/f1/edit/logic` doesn't also light up an `/forms/f1/edit` Questions tab that isn't marked `end`.
packages/ui/src/components/layout/sub-nav.tsx
@marktiderman/genesis-ui/layoutimport { mostSpecificActive } from "@marktiderman/genesis-ui/layout";react-docgen-typescript.mostSpecificActive
Of several matching items, the one whose path matches most specifically, so `/forms/f1/edit/logic` doesn't also light up an `/forms/f1/edit` Questions tab that isn't marked `end`.
No declared props.
SubNavTabs
A row of navigation tabs: real links (deep links and middle-click work), `aria-current="page"` on the active one, badges as chips, the active tab underlined in the brand colour. AppShell renders it in `tabs` mode; an app using `subNav: "off"` can place it itself.
| Prop | Type | Default | Description |
|---|---|---|---|
| items* | SubNavItem[] | — | |
| linkComponent* | LinkComponent | — | |
| activePath | string | — | Current location (`pathname + search + hash`); drives the active tab. |
| className | string | — | |
| end | ReactNode | — | Right-aligned slot in the row, e.g. a "Ready to publish" chip. |
| isActive | ((to: string, activePath?: string) => boolean) | — | |
| label | string | — | Accessible name of the `<nav>` (default "Page sections"). |
| variant | enum | primary | `primary` (default): the page's tab row. `secondary`: a smaller, quieter row for a tabbed level inside another, drawn under the primary row. |
layoutSubNavLevels
How AppShell draws a set of levels, outermost first. Tabbed levels stack as two rows at most (primary, then secondary); the levels above the last two fold into breadcrumb pickers. The innermost `list` level is drawn as a list, and a `hub` level as cards. Pure: AppShell and the tests share it.
No declared props.
SubNavSegmented
A segmented control of links: the phone form of a second tab row. Each segment is a real link with `aria-current` on the active one, at least 44px tall on touch; the control scrolls sideways when it doesn't fit.
| Prop | Type | Default | Description |
|---|---|---|---|
| items* | SubNavItem[] | — | |
| linkComponent* | LinkComponent | — | |
| activePath | string | — | |
| className | string | — | |
| isActive | ((to: string, activePath?: string) => boolean) | — | |
| label | string | — | Accessible name of the `<nav>`. |
SubNavBreadcrumb
The outer tab levels folded into a breadcrumb: one picker per level, showing its current item and opening the level's other items. AppShell draws it above the two tab rows when a third tabbed level is open.
| Prop | Type | Default | Description |
|---|---|---|---|
| levels* | Pick<SubNavLevel, "label" | "items">[] | — | The folded levels, outermost first. |
| linkComponent* | LinkComponent | — | |
| activePath | string | — | |
| className | string | — | |
| isActive | ((to: string, activePath?: string) => boolean) | — |
SubNavList
A level's children as a vertical list of links: a column beside the content on a wide screen, or full-width rows (a phone's list page).
| Prop | Type | Default | Description |
|---|---|---|---|
| items* | SubNavItem[] | — | |
| linkComponent* | LinkComponent | — | |
| activePath | string | — | |
| className | string | — | |
| isActive | ((to: string, activePath?: string) => boolean) | — | |
| label | string | — | |
| variant | enum | column | `column` (default): a list beside the content. `page`: full-width rows with a chevron, a phone's list page. |
SubNavHub
A level's children as cards, one per child (icon, label, badge): a section's landing page. One column on a phone, more as the width allows.
| Prop | Type | Default | Description |
|---|---|---|---|
| items* | SubNavItem[] | — | |
| linkComponent* | LinkComponent | — | |
| className | string | — | |
| label | string | — |
useAppShellSubNav
Give the shell this page's child items (sub-navigation) while the page is mounted. They replace the current `NavigationNode`'s `items`; pass `null` / `undefined` to fall back to them (a `mode` still applies). When several components call it (a layout and its page), the innermost wins, for items and for mode separately. Use it when children depend on page data, such as live badge counts. A fresh array each render is fine: the shell only updates when a `to`, label, badge, icon or flag changes. ```tsx useAppShellSubNav([ { to: `/forms/${id}/edit`, label: "Questions", icon: ListChecks, badge: questions.length, end: true }, { to: `/forms/${id}/edit/logic`, label: "Logic and endings", icon: GitBranch, badge: rules.length }, { to: `/forms/${id}/edit/responses`, label: "Responses", icon: Inbox, badge: responses }, { to: `/forms/${id}/edit/settings`, label: "Settings", icon: Settings }, ]); ``` Does nothing outside an `AppShell`.
No declared props.
AppShellSubNavEnd
Render `children` in the right-hand slot of the shell's sub-navigation tab row, e.g. a "Ready to publish" status chip. Rendered through a portal, so it keeps the page's context and state. On phones, where the bottom bar replaces the tab row, it renders in a compact strip under the page header instead, so the chip stays reachable. Renders nothing when the shell has no tab row (other modes, a page without children). When several are mounted (a layout's and a page's), the innermost renders.
No declared props.
AppShellPageHeader
Render the page's resource header (breadcrumb, title, status, actions) at the top of the shell's content, ABOVE the sub-navigation tab row, where the design puts it. A portal like `AppShellSubNavEnd`, so it keeps the page's state; the innermost mounted one renders. On phones it stays at the top of the content while the bottom bar carries the children. With no tab row (the default `"section"` mode, or a page without children) it simply sits at the top of the content. Mount none and the layout is unchanged.
No declared props.
SubNavContext
No declared props.