Headers & navigation / Tab bars

Sticky Pill Sub-Navigation

A white pill-shaped floating bar with soft shadow, holding in-page anchors (Standard pricing, Custom pricing, FAQs). It centers near the bottom of the hero and then pins to the top when scrolling.

Rebuilt from stripe.com/pricing in the Iridescent Ledger style.

npx shadcn@latest add https://justyoink.it/r/iridescent-ledger/blocks/capsule-subnav.json

Looks exactly like stripe.com: brings its fonts and colours, namespaced so your own theme stays untouched.

Usage

Pass `items` (id + label) matching your section ids, `defaultActive`, and `pinOffset` (scroll px before the bar pins to the top). Clicking an anchor tints it with the accent pill.

components/capsule-subnav.tsx
import { useEffect, useState } from "react";

type Item = { id: string; label: string };

export default function StickySubNav({
  items = [
    { id: "standard", label: "Standard pricing" },
    { id: "custom", label: "Custom pricing" },
    { id: "faqs", label: "FAQs" },
  ],
  defaultActive = "standard",
  pinOffset = 240,
}: {
  items?: Item[];
  defaultActive?: string;
  pinOffset?: number;
}) {
  const [active, setActive] = useState(defaultActive);
  const [pinned, setPinned] = useState(false);

  useEffect(() => {
    const onScroll = () => setPinned(window.scrollY > pinOffset);
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, [pinOffset]);

  return (
    <div className={pinned ? "fixed inset-x-0 top-3 z-50 flex justify-center px-4" : "relative flex justify-center px-4 py-6"}>
      <nav
        aria-label="On this page"
        className={"flex items-center gap-1 rounded-pill bg-surface p-1.5 shadow-floating transition-all duration-[250ms] ease-smooth motion-reduce:transition-none " + (pinned ? "animate-[none] translate-y-0 opacity-100" : "")}
      >
        {items.map((it) => {
          const on = active === it.id;
          return (
            <a
              key={it.id}
              href={"#" + it.id}
              aria-current={on ? "true" : undefined}
              onClick={() => setActive(it.id)}
              className={"rounded-pill px-4 py-2 text-ui font-medium transition-colors duration-link ease-link focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent " + (on ? "bg-accent-soft text-ink-deep" : "text-ink hover:bg-accent-wash")}
            >
              {it.label}
            </a>
          );
        })}
      </nav>
    </div>
  );
}

Quality checks

Automated, in a real browser · 5d ago
—

More from Iridescent Ledger

The whole style →

Checklist Feature Columns

Feature sections

Iridescent Ribbon Hero

Heroes

Dated Article Row

Blog & articles

Saturated Highlight Card Strip

Carousels

Frosted Hairline Header

Headers & nav bars

Mockup Bento Grid

Feature sections