Route Tabs

A row of links between the pages of one section.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/route-nav

Usage

import { RouteNav } from "./ui/uicontext/components/kit/RouteNav.ts"
export const SettingsNav = <M>(h: Html.H<M>, current: string) =>	RouteNav(h, {		label: "Settings",		current,		items: [			{ id: "general", label: "General", href: "/settings" },			{ id: "members", label: "Members", href: "/settings/members" },			{ id: "billing", label: "Billing", href: "/settings/billing" },		],	})

Examples

Narrower than its links

The row scrolls sideways instead of wrapping, and the current page scrolls into view.

API reference

Options

RouteNav options
NameTypeDescription
labelrequiredstringThe landmark's accessible name: "Settings".
itemsrequiredRouteNavItem[]The links, each with an id, a label, an href and an optional glyph.
currentstringThe id of the link to the page shown now, marked as the current page.
styleStyleStyleX styles for the row.
linkStyleStyleApplied to every anchor after its default styles.
currentStyleStyleApplied last to the current anchor.
glyphStyleStyleStyleX styles for each link's glyph.

Accessibility

  • A nav landmark named by its label, holding real links; the current page is aria-current="page".

Source