Folio Navbar
A site navbar on a warm paper ground with a serif nameplate, a folio-style issue number, a button and a row of links under a hairline.
import { cn } from "cn"
import { Hairline } from "@/components/hairline/hairline"
import { Paper } from "@/components/texture/paper"
import { buttonVariants } from "@/components/ui/button"
// The copy: change text here, not in the markup.
const COPY = {
brand: "Almanac",
issue: "No. 38",
season: "Spring edition",
cta: "Read the issue",
} as const
const LINKS = [
{ label: "Contents", href: "#" },
{ label: "Letters", href: "#" },
{ label: "Recipes", href: "#" },
{ label: "Back issues", href: "#" },
] as const
// Paper texture on a warm ground: the bar reads as the top of a printed page,
// with the issue number set like a folio.
export default function PaperFolioNavbar() {
return (
<header className="relative isolate w-full overflow-hidden bg-background text-foreground">
<Paper className="-z-10 [--paper-color:var(--foreground)]" />
<div className="mx-auto grid w-full max-w-7xl grid-cols-[1fr_auto] items-center gap-x-6 gap-y-4 px-6 py-6 md:grid-cols-[1fr_auto_1fr] lg:px-10">
<div className="flex flex-col gap-0.5 text-sm">
<span>{COPY.issue}</span>
<span className="opacity-70">{COPY.season}</span>
</div>
<a
href="#"
className="order-first col-span-2 justify-self-center rounded-sm font-display text-5xl/none outline-none [--font-display:var(--font-serif)] focus-visible:ring-3 focus-visible:ring-ring/50 md:order-none md:col-span-1 md:text-6xl/none"
>
{COPY.brand}
</a>
<a
href="#"
className={cn(buttonVariants({ size: "sm" }), "justify-self-end")}
>
{COPY.cta}
</a>
<Hairline className="col-span-full" />
<nav aria-label="Main" className="col-span-full">
<ul className="flex flex-wrap justify-center gap-x-10 gap-y-2">
{LINKS.map((link) => (
<li key={link.label}>
<a
href={link.href}
className="rounded-sm text-sm underline-offset-4 outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50"
>
{link.label}
</a>
</li>
))}
</ul>
</nav>
</div>
</header>
)
}
import type { ComponentProps } from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import { Separator } from "@/components/ui/separator"
/**
* ends paints the line as a gradient so it dissolves over its first and last
* tenth instead of stopping; Separator's own bg-border has to go, or it shows
* through the transparent ends.
*/
const hairlineVariants = cva("", {
variants: {
/**
* How the line ends. `ends` (the default) fades it out over the first
* and last tenth, so a full-width line never reads as a bar across the
* page. `none` is a plain line, for a rule inside a frame.
*/
fade: {
ends: "bg-transparent data-horizontal:bg-[linear-gradient(to_right,transparent,var(--border)_10%,var(--border)_90%,transparent)] data-vertical:bg-[linear-gradient(to_bottom,transparent,var(--border)_10%,var(--border)_90%,transparent)]",
none: "",
},
},
defaultVariants: { fade: "ends" },
})
/**
* A 1px rule in the border color whose ends dissolve: the line between two
* sections of a page. It is the stock `Separator` underneath, so it takes
* `orientation` and `className` the same way.
*
* `fade="ends"` (the default) paints the line as a gradient, transparent at
* each end and the border color from 10% to 90%. `fade="none"` is a plain
* line. `decorative` (the default) hides it from assistive technology, since
* two sections are already separate landmarks; pass `decorative={false}` for
* a separator that means something, such as one between groups in a list.
* It carries no margin: leave the space around it to the layout, as with
* any rule.
*/
function Hairline({
className,
fade = "ends",
decorative = true,
...props
}: ComponentProps<typeof Separator> &
VariantProps<typeof hairlineVariants> & {
/** Hide the line from assistive technology (the default). `false` keeps the separator role. */
decorative?: boolean
}) {
return (
<Separator
data-slot="hairline"
data-fade={fade}
aria-hidden={decorative || undefined}
className={cn(hairlineVariants({ fade }), className)}
{...props}
/>
)
}
export { Hairline, hairlineVariants }
import { cn } from "cn"
type Intensity = "fine" | "default" | "rich"
// One scale for every texture; `default` is the unscaled value.
const INTENSITY_MULT: Record<Intensity, number> = {
fine: 0.6,
default: 1,
rich: 1.45,
}
const alpha = (base: number, mult: number) => (base * mult).toFixed(4)
// Off-axis fiber angles (3°, -2°, 1°) + three repeat intervals avoid moiré.
/** Full-bleed art layer — drop inside a `relative` parent; sits behind content. */
function Paper({
intensity = "default",
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Fiber alpha multiplier. Ink is white; set --paper-color on a light ground.
*/
intensity?: Intensity
}) {
const m = INTENSITY_MULT[intensity]
return (
<div
className={cn("pointer-events-none absolute inset-0", className)}
aria-hidden="true"
data-slot="paper"
{...props}
>
<div
className="absolute inset-0"
style={{
backgroundImage: `
repeating-linear-gradient(3deg in srgb, transparent 0px, transparent 6px, oklch(from var(--paper-color, oklch(1 0 0)) l c h / ${alpha(0.04, m)}) 6px, oklch(from var(--paper-color, oklch(1 0 0)) l c h / ${alpha(0.02, m)}) 7px),
repeating-linear-gradient(-2deg in srgb, transparent 0px, transparent 8px, oklch(from var(--paper-color, oklch(1 0 0)) l c h / ${alpha(0.03, m)}) 8px, oklch(from var(--paper-color, oklch(1 0 0)) l c h / ${alpha(0.01, m)}) 9px),
repeating-linear-gradient(1deg in srgb, transparent 0px, transparent 12px, oklch(from var(--paper-color, oklch(1 0 0)) l c h / ${alpha(0.02, m)}) 12px, oklch(from var(--paper-color, oklch(1 0 0)) l c h / ${alpha(0.01, m)}) 13px)
`,
}}
/>
</div>
)
}
export { Paper }
Installation
pnpm dlx shadcn@latest add @01orbital/folio-navbar-01npx shadcn@latest add @01orbital/folio-navbar-01yarn dlx shadcn@latest add @01orbital/folio-navbar-01bunx --bun shadcn@latest add @01orbital/folio-navbar-01Make it yours
- Its words are in
COPYat the top ofcomponents/blocks/site-nav/folio-navbar-01/index.tsx: change them there, not in the markup. LINKS, also at the top of the file, holds its lists and settings.- Its look comes from Paper; each page lists the props that change it.
Built from
npm: @01orbital/font-geist-serif, cn. The CLI installs them for you.
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.
Last updated on