Route Tabs

View as Markdown

A row of links between the pages of one section.

When to use

A row of links between the pages of one section. Use Tabs instead when the panels change without a new address.

Usage

import { RouteNav } from "./ui/uicontext/components/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.

Keyboard and accessibility

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

Installation

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

Source