Nav Bar

@sushindustries/ui

A site header whose panels expand, built on <details> so it works before hydration.

12 min read
View as MarkdownEdit on GitHub
Viewport width
Phone22remthe floor, the narrowest this promises to work at
tanstacktanstack add https://adamjurek.com/r/tanstack/nav-bar.jsonshadcnpnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/nav-bar.json

Press Compare, then open a panel at each width. The mobile view collapses every entry into one burger; the desktop and tablet views keep the row and narrow only the panel that opens under it.

In a page

import { NavBar } from "@sushindustries/ui";
import { Link, useRouter } from "@tanstack/react-router";

export function SiteHeader() {
	const router = useRouter();

	return (
		<NavBar
			brand={<span>My Site</span>}
			entries={[{ id: "work", label: "Work", href: "/work" }]}
			renderLink={({ href, className, children }) => (
				<Link to={href} className={className}>
					{children}
				</Link>
			)}
		/>
	);
}
tsx

What this example is not

renderLink here is written for TanStack Router specifically. The prop itself is router-agnostic - swap the body for whatever Link component the host actually uses, or leave it out entirely for plain anchors.

UsesIconIconThe glyph set, generated from a Markdown table where every drawing carries its reason. One component, typed names, no icon font.@sushindustries/ui · content