Components93 / 118
Orbit Nav
A compact black pill navigation that unrolls out of its planet mark, stretching past its length and settling. Link letters roll over one by one, the planet's moon swings round its ring, and the email pill squashes, copies the address and morphs to Copied.
NavbarNavbarHeaderHeaderCopy emailCopy emailLetter rollLetter rollSquash & stretchSquash & stretchGSAPGSAP
Point at the links and the planetClick the email to copy it
Tweak
LIVELIVELook
48px
Usage
Follows your tweaks.
usage.tsx
import { OrbitNav } from "@/components/inreact/orbit-nav";
export function Header() {
return (
<header className="fixed inset-x-0 top-6 z-50 flex justify-center">
<OrbitNav
links={[{ label: "Work", href: "/work" }, { label: "About", href: "/about" }, { label: "Playground", href: "/playground" }, { label: "Resource", href: "/resource" }]}
email="hello@northlab.co"
/>
</header>
);
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/orbit-nav.jsonOr copy the source
Install the dependencies, then save this as components/inreact/orbit-nav.tsx.
terminal
npm install gsapcomponents/inreact/orbit-nav.tsx
"use client";
import { gsap } from "gsap";
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from "react";
/**
* Orbit Nav: a compact black pill navigation with a planet mark and a copy-email button.
*
* On load the bar unrolls out of the planet: the mark pops in with a spin, the
* pill stretches out past its length, squashes and settles, and the links
* slide in one after another. Point at a link and its letters roll over one
* by one (a small dip first, then up with an overshoot). Point at the planet
* and its moon swings round the ring, passing behind the planet and in front.
* The email button copies the address: it squashes as you press, then the
* address rolls away to "Copied" and back.
*
* <OrbitNav links={[{ label: "Work", href: "/work" }]} email="hello@northlab.co" />
*/
export interface OrbitNavLink {
label: string;
href: string;
}
export interface OrbitNavProps {
links?: OrbitNavLink[];
email?: string;
/** Replaces the planet mark. */
logo?: ReactNode;
logoHref?: string;
/** Bar height, px (everything scales from it). */
size?: number;
/** Play the unroll entrance on mount. */
intro?: boolean;
onCopy?: (email: string) => void;
className?: string;
}
const DEFAULT_LINKS: OrbitNavLink[] = [
{ label: "Work", href: "#work" },
{ label: "About", href: "#about" },
{ label: "Playground", href: "#playground" },
{ label: "Resource", href: "#resource" },
];
const reduced = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
/** Letters that roll over: each one has a copy waiting underneath. */
function Roll({ text, lineH }: { text: string; lineH: number }) {
return (
<span aria-hidden="true" className="relative block overflow-hidden whitespace-nowrap" style={{ height: lineH, lineHeight: `${lineH}px` }}>
{[...text].map((ch, i) => (
<span key={i} data-ch className="relative inline-block will-change-transform">
<span className="block">{ch === " " ? " " : ch}</span>
<span className="absolute top-full left-0 block">{ch === " " ? " " : ch}</span>
</span>
))}
</span>
);
}
const roll = (el: HTMLElement | null, on: boolean) => {
if (!el || reduced()) return;
const chs = el.querySelectorAll("[data-ch]");
gsap.killTweensOf(chs);
// anticipation: a small dip the other way, then over with an overshoot
gsap
.timeline()
.to(chs, { yPercent: on ? 14 : -114, duration: 0.09, ease: "power1.out", stagger: 0.018 })
.to(chs, { yPercent: on ? -100 : 0, duration: 0.5, ease: "back.out(2.2)", stagger: 0.018 }, 0.06);
};
function Planet({ d }: { d: number }) {
const ref = useRef<SVGSVGElement>(null);
useEffect(() => {
const svg = ref.current;
if (!svg) return;
const back = svg.querySelector<SVGCircleElement>("[data-moon=back]")!;
const front = svg.querySelector<SVGCircleElement>("[data-moon=front]")!;
const ring = svg.querySelector<SVGGElement>("[data-ring]")!;
// the moon only shows while it swings round: it pops out, orbits once and tucks away
const o = { t: Math.PI * 0.9, s: 0 };
const put = () => {
const x = 12 + Math.cos(o.t) * 10, y = 12 + Math.sin(o.t) * 3.6;
for (const m of [back, front]) m.setAttribute("cx", x.toFixed(2)), m.setAttribute("cy", y.toFixed(2)), m.setAttribute("r", (1.7 * o.s).toFixed(2));
const inFront = Math.sin(o.t) > 0; // the lower half of the ring is the near side
front.style.opacity = inFront ? "1" : "0";
back.style.opacity = inFront ? "0" : "1";
};
put();
const btn = svg.closest("a");
if (!btn) return;
const enter = () => {
if (reduced()) return;
gsap.killTweensOf(o);
o.t = Math.PI * 0.9;
gsap
.timeline({ onUpdate: put })
.to(o, { s: 1, duration: 0.25, ease: "back.out(3)" }, 0)
.to(o, { t: Math.PI * 2.9, duration: 1.2, ease: "power2.inOut" }, 0)
.to(o, { s: 0, duration: 0.22, ease: "power2.in" }, 1.0);
// the ring tips with the swing and wobbles back
gsap.killTweensOf(ring);
gsap.timeline().to(ring, { rotation: -14, svgOrigin: "12 12", duration: 0.35, ease: "power2.out" }).to(ring, { rotation: 0, svgOrigin: "12 12", duration: 1.1, ease: "elastic.out(1, 0.35)" });
};
btn.addEventListener("pointerenter", enter);
return () => btn.removeEventListener("pointerenter", enter);
}, []);
return (
<svg ref={ref} viewBox="0 0 24 24" width={d * 0.7} height={d * 0.7} aria-hidden="true" className="overflow-visible">
<g transform="rotate(-24 12 12)">
<g data-ring>
<circle data-moon="back" r="0" fill="#141414" />
<ellipse cx="12" cy="12" rx="10" ry="3.6" fill="none" stroke="#141414" strokeWidth="1.7" />
<circle cx="12" cy="12" r="5.6" fill="#141414" stroke="#fff" strokeWidth="1.4" />
<path d="M2 12 A10 3.6 0 0 0 22 12" fill="none" stroke="#141414" strokeWidth="1.7" />
<circle data-moon="front" r="0" fill="#141414" stroke="#fff" strokeWidth="0.9" />
</g>
</g>
</svg>
);
}
export function OrbitNav({ links = DEFAULT_LINKS, email = "hello@northlab.co", logo, logoHref = "/", size = 48, intro = true, onCopy, className }: OrbitNavProps) {
const rootRef = useRef<HTMLElement>(null);
const bgRef = useRef<HTMLSpanElement>(null);
const rowRef = useRef<HTMLDivElement>(null);
const markRef = useRef<HTMLAnchorElement>(null);
const pillRef = useRef<HTMLButtonElement>(null);
const aRef = useRef<HTMLSpanElement>(null);
const bRef = useRef<HTMLSpanElement>(null);
const [copied, setCopied] = useState(false);
const pad = Math.round(size * 0.1);
const d = size - pad * 2;
const font = size * 0.29;
const lineH = Math.round(font * 1.35);
// the entrance: the bar unrolls out of the planet, stretches past its length and settles
useLayoutEffect(() => {
const root = rootRef.current, bg = bgRef.current, row = rowRef.current, mark = markRef.current;
if (!root || !bg || !row || !mark) return;
if (!intro || reduced()) return;
const W = root.offsetWidth;
const items = row.querySelectorAll("[data-item]");
const p = { w: size };
const draw = () => {
bg.style.width = `${p.w.toFixed(2)}px`;
row.style.clipPath = `inset(0 ${Math.max(0, W - p.w).toFixed(2)}px 0 0 round ${size / 2}px)`;
};
draw();
const tl = gsap.timeline({
onComplete: () => {
bg.style.width = "100%";
row.style.clipPath = "";
},
});
tl.fromTo(mark, { scale: 0, rotation: -120 }, { scale: 1, rotation: 0, duration: 0.6, ease: "back.out(2.2)" }, 0)
.to(p, { w: W, duration: 0.95, ease: "back.out(1.3)", onUpdate: draw }, 0.32)
// squash as it stretches out, then a springy settle
.to(bg, { scaleY: 0.9, duration: 0.32, ease: "power2.out" }, 0.32)
.to(bg, { scaleY: 1, duration: 0.8, ease: "elastic.out(1, 0.4)" }, 0.64)
.fromTo(items, { x: -14, opacity: 0 }, { x: 0, opacity: 1, duration: 0.55, ease: "back.out(2)", stagger: 0.055 }, 0.45);
return () => {
tl.kill();
bg.style.width = "100%";
row.style.clipPath = "";
gsap.set([mark, bg, ...items], { clearProps: "transform,opacity" });
};
}, [intro, size, links.map((l) => l.label).join("|")]); // eslint-disable-line react-hooks/exhaustive-deps
// the email pill keeps one width (the wider label), so the bar never shifts when it morphs
const widths = useRef({ a: 0, b: 0 });
useLayoutEffect(() => {
const pill = pillRef.current, a = aRef.current, b = bRef.current;
if (!pill || !a || !b) return;
const padX = size * 0.36;
widths.current = { a: a.offsetWidth + padX * 2, b: b.offsetWidth + padX * 2 };
gsap.set(pill, { width: Math.max(widths.current.a, widths.current.b) });
}, [size, email]); // eslint-disable-line react-hooks/exhaustive-deps
const timer = useRef(0);
useEffect(() => () => window.clearTimeout(timer.current), []);
const morph = (on: boolean) => {
const pill = pillRef.current, a = aRef.current, b = bRef.current;
if (!pill || !a || !b) return;
setCopied(on);
const still = reduced();
const [out, inn] = on ? [a, b] : [b, a];
gsap.to(out, { yPercent: -110, opacity: 0, duration: still ? 0 : 0.22, ease: "power2.in", overwrite: true });
gsap.fromTo(inn, { yPercent: 110, opacity: 0 }, { yPercent: 0, opacity: 1, duration: still ? 0 : 0.5, ease: "back.out(2)", delay: still ? 0 : 0.1, overwrite: true });
};
const copy = () => {
const pill = pillRef.current;
if (pill && !reduced()) {
// press: squash wide and low, then spring back like jelly
gsap.killTweensOf(pill, "scaleX,scaleY,scale");
gsap.timeline().to(pill, { scaleX: 1.07, scaleY: 0.86, duration: 0.09, ease: "power2.out" }).to(pill, { scaleX: 1, scaleY: 1, duration: 0.75, ease: "elastic.out(1, 0.35)" });
}
navigator.clipboard?.writeText(email).catch(() => {});
onCopy?.(email);
window.clearTimeout(timer.current);
morph(true);
timer.current = window.setTimeout(() => morph(false), 1800);
};
return (
<nav ref={rootRef} aria-label="Main" className={["relative inline-flex select-none", className].filter(Boolean).join(" ")} style={{ height: size, fontSize: font }}>
<span
ref={bgRef}
aria-hidden="true"
className="absolute top-0 left-0 h-full w-full origin-left rounded-full bg-[#141414]"
style={{ boxShadow: "0 1px 2px rgba(0,0,0,.10), 0 6px 14px -4px rgba(0,0,0,.18), 0 22px 40px -14px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.06)" }}
/>
<div ref={rowRef} className="relative flex items-center" style={{ padding: pad, gap: size * 0.06 }}>
<a ref={markRef} href={logoHref} aria-label="Home" className="grid shrink-0 cursor-pointer place-items-center rounded-full bg-white outline-none focus-visible:ring-2 focus-visible:ring-white/50" style={{ width: d, height: d }}>
{logo ?? <Planet d={d} />}
</a>
<div className="flex items-center" style={{ margin: `0 ${size * 0.14}px` }}>
{links.map((l) => (
<a
key={l.label}
data-item
href={l.href}
aria-label={l.label}
onPointerEnter={(e) => roll(e.currentTarget, true)}
onPointerLeave={(e) => roll(e.currentTarget, false)}
onFocus={(e) => roll(e.currentTarget, true)}
onBlur={(e) => roll(e.currentTarget, false)}
className="rounded-full font-medium text-white/90 outline-none focus-visible:ring-2 focus-visible:ring-white/40"
style={{ padding: `0 ${size * 0.27}px` }}
>
<Roll text={l.label} lineH={lineH} />
</a>
))}
</div>
<button
ref={pillRef}
data-item
type="button"
onClick={copy}
onPointerEnter={(e) => !reduced() && gsap.to(e.currentTarget, { scale: 1.04, duration: 0.45, ease: "back.out(2.5)" })}
onPointerLeave={(e) => !reduced() && gsap.to(e.currentTarget, { scale: 1, duration: 0.5, ease: "back.out(2)" })}
aria-label={copied ? "Email copied" : `Copy ${email}`}
className="relative grid shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-0 bg-white font-medium text-[#141414] outline-none focus-visible:ring-2 focus-visible:ring-white/50"
style={{ height: d, font: "inherit", fontWeight: 500 }}
>
<span ref={aRef} className="col-start-1 row-start-1 block whitespace-nowrap">
{email}
</span>
<span ref={bRef} className="col-start-1 row-start-1 flex items-center whitespace-nowrap opacity-0" style={{ gap: size * 0.1 }}>
<svg viewBox="0 0 16 16" width={font} height={font} aria-hidden="true">
<path d="M3 8.5l3.2 3L13 4.5" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
</svg>
Copied
</span>
<span className="sr-only" aria-live="polite">
{copied ? "Copied" : ""}
</span>
</button>
</div>
</nav>
);
}
export default OrbitNav;
One prompt, any AI agent
Paste into Claude Code, Codex, Cursor or Windsurf. It carries your tweaks and the full source, so the agent installs it exactly.
Props
8 propslinks{ label, href }[]The links in the middle.emailstringAddress the right-hand pill copies.default "hello@northlab.co"default "hello@northlab.co"logoReactNodeReplaces the planet mark.logoHrefstringWhere the mark links to.default "/"default "/"sizenumberBar height, px (everything scales from it).default 48default 48introbooleanPlay the unroll entrance on mount.default truedefault trueonCopy(email) => voidCalled after the address is copied.classNamestringExtra classes.