Headers & navigation / Tab bars

Pill Tab Switcher

A light grey rounded track of text tabs; the active tab is a solid black pill with white text and inactive tabs are grey. Used for feature categories and a Personal/Work toggle.

Rebuilt from arc.net in the Obsidian Farewell Editorial style.

npx shadcn@latest add https://justyoink.it/r/obsidian-farewell-editorial/blocks/pill-tabs.json

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

Usage

Props: `heading` and `tabs` (array of {id, label, title, body, items}). Renders standalone with defaults; clicking a pill swaps the panel with a slide-and-fade.

components/pill-tabs.tsx
"use client";

import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react";
import { useState } from "react";

type Tab = { id: string; label: string; title: string; body: string; items: string[] };

const DEFAULT_TABS: Tab[] = [
  { id: "import", label: "Import", title: "Bring everything across", body: "Move your saved pages, groups and preferences in a few clicks, with nothing left behind.", items: ["Saved pages", "Groups", "Preferences"] },
  { id: "speed", label: "Speed", title: "Fast from the first launch", body: "A lean engine keeps pages snappy even with dozens of open windows.", items: ["Quick start", "Low memory", "Smooth scroll"] },
  { id: "privacy", label: "Privacy", title: "Private by default", body: "Tracking is blocked out of the box and your data stays on your device.", items: ["Tracker blocking", "Local storage", "Clear history"] },
  { id: "sync", label: "Sync", title: "Pick up anywhere", body: "Your workspace follows you between machines without any setup.", items: ["Devices", "Profiles", "Backups"] },
];

export default function PillTabSwitcher({
  heading = "Make the move to a calmer browser",
  tabs = DEFAULT_TABS,
}: {
  heading?: string;
  tabs?: Tab[];
}) {
  const [active, setActive] = useState(tabs[0]?.id);
  const current = tabs.find((t) => t.id === active) ?? tabs[0];

  return (
    <section className="bg-canvas px-6 py-20 text-ink">
      <style>{`@keyframes pts-in{from{opacity:0;transform:translateX(16px)}to{opacity:1;transform:none}}.pts-in{animation:pts-in .35s ease-out both}@media (prefers-reduced-motion:reduce){.pts-in{animation:none}}`}</style>
      <Reveal className="mx-auto flex max-w-3xl flex-col items-center text-center">
        <h2 className="font-display text-h2 text-ink-soft">{heading}</h2>
        <div role="tablist" aria-label="Categories" className="mt-8 inline-flex max-w-full flex-wrap justify-center gap-1 rounded-pill bg-surface-tint p-1 shadow-inset-soft">
          {tabs.map((t) => {
            const on = t.id === current.id;
            return (
              <button
                key={t.id}
                role="tab"
                aria-selected={on}
                onClick={() => setActive(t.id)}
                className={`rounded-pill px-4 py-2 text-ui transition-colors duration-200 focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus-ring ${on ? "bg-ink text-white" : "bg-transparent text-faint hover:text-ink"}`}
              >
                {t.label}
              </button>
            );
          })}
        </div>
        <div key={current.id} role="tabpanel" className="pts-in mt-10 w-full rounded-xl border border-hairline bg-bar-glass p-8 text-left shadow-float">
          <h3 className="font-display text-subhead text-ink-soft">{current.title}</h3>
          <p className="mt-3 text-body text-muted">{current.body}</p>
          <ul className="mt-6 flex flex-wrap gap-2">
            {current.items.map((i) => (
              <li key={i} className="rounded-pill bg-surface-tint px-3 py-1 text-caption text-ink">{i}</li>
            ))}
          </ul>
        </div>
      </Reveal>
    </section>
  );
}

// ---- Yoink motion (inlined, no dependencies): Reveal ----

const YK_EASE = "cubic-bezier(0.16, 1, 0.3, 1)";

const useYkLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;

function ykReducedMotion(): boolean {
  return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
}

// "idle": untouched (visible) · "hidden": waiting below the fold · "shown": play the entrance.
// Content is only hidden once we know we can show it again (IntersectionObserver exists, motion allowed,
// and there is a box to watch), and a safety net reveals anything on screen that is still hidden.
type YkRevealState = "idle" | "hidden" | "shown";

function useYkReveal(ref: RefObject<Element | null>, once = true): YkRevealState {
  const [state, setState] = useState<YkRevealState>("idle");
  useYkLayoutEffect(() => {
    const el = ref.current;
    if (!el || ykReducedMotion() || typeof IntersectionObserver === "undefined") return;
    // watch the element's own box, or its children when it has none (display: contents)
    const boxes = () => (getComputedStyle(el).display === "contents" ? Array.from(el.children) : [el]);
    const onScreen = (t: Element) => {
      const r = t.getBoundingClientRect();
      return (r.width > 0 || r.height > 0) && r.bottom > 0 && r.right > 0 && r.top < window.innerHeight && r.left < window.innerWidth;
    };
    if (!boxes().some((t) => t.getBoundingClientRect().width > 0 || t.getBoundingClientRect().height > 0)) return; // e.g. hidden at mount: leave it visible
    let shown = false;
    const show = (v: boolean) => {
      if (v !== shown) (shown = v), setState(v ? "shown" : "hidden");
    };
    setState("hidden");
    const inView = new Set<Element>();
    const io = new IntersectionObserver((entries) => {
      for (const e of entries) {
        if (e.isIntersecting) inView.add(e.target);
        else inView.delete(e.target);
      }
      if (inView.size) {
        show(true);
        if (once) io.disconnect();
      } else if (!once) show(false);
    });
    const watched = new Set<Element>();
    const watch = () => boxes().forEach((t) => !watched.has(t) && (watched.add(t), io.observe(t)));
    watch();
    // safety net: styles that land after mount (display: contents) get watched too, and nothing
    // stays hidden for more than a moment while it is actually on screen
    const start = Date.now();
    const net = setInterval(() => {
      if (shown) return once && clearInterval(net);
      watch();
      if (Date.now() - start > 2400 && boxes().some(onScreen)) show(true);
    }, 600);
    return () => {
      io.disconnect();
      clearInterval(net);
    };
  }, [once]);
  return state;
}

type YkRevealFrom = "up" | "down" | "left" | "right" | "scale" | "blur" | "none";

/** Fades content in as it scrolls into view. */
function Reveal({
  children,
  from = "up",
  delay = 0,
  duration = 700,
  distance = 24,
  once = true,
  as = "div",
  className,
  style,
}: {
  children?: ReactNode;
  from?: YkRevealFrom;
  delay?: number;
  duration?: number;
  distance?: number;
  once?: boolean;
  as?: ElementType;
  className?: string;
  style?: CSSProperties;
}) {
  const Tag = as;
  const ref = useRef<HTMLElement>(null);
  const state = useYkReveal(ref, once);
  const hidden = state === "hidden";
  const offset = {
    up: `translate3d(0, ${distance}px, 0)`,
    down: `translate3d(0, ${-distance}px, 0)`,
    left: `translate3d(${-distance}px, 0, 0)`,
    right: `translate3d(${distance}px, 0, 0)`,
    scale: "scale(0.94)",
    blur: `translate3d(0, ${distance / 2}px, 0)`,
    none: "none",
  }[from];
  const t = `${duration}ms ${YK_EASE} ${delay}ms`;
  return (
    <Tag
      ref={ref}
      className={className}
      style={{
        ...style,
        ...(hidden && { opacity: 0, transform: offset, filter: from === "blur" ? "blur(12px)" : undefined }),
        ...(state === "shown" && { transition: `opacity ${t}, transform ${t}, filter ${t}` }),
      }}
    >
      {children}
    </Tag>
  );
}

Quality checks

Automated, in a real browser · 4d ago
—

More from Obsidian Farewell Editorial

The whole style →

Hairline FAQ Accordion

Accordions

Signature Scatter Hero

Heroes

Sticky Glass Promo Banner

Toasts & snackbars

Fading Vertical Timeline

Lists

Centered Serif Section Header

Other

Frosted Browser Mockup Card

Media & mockups