Page sections / Feature sections

API Step Accordion with Code Pane

Dot-grid backdrop with eyebrow label and gradient heading; left a stack of rounded step cards with icon squares and a blue POST badge (active one expands with a description and blue edge), right a hairline code window with traffic-light circles, language dropdown and copy button.

Rebuilt from resend.com/products/inboxes in the Obsidian Serif Glow style.

npx shadcn@latest add https://justyoink.it/r/obsidian-serif-glow/blocks/api-step-list-with-code.json

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

Usage

Props: eyebrow, titleTop, titleBottom, subtitle, and steps (title, badge, icon, description, code lines). Click a card to expand it and swap the code; the badge fades in after 300ms.

components/api-step-list-with-code.tsx
"use client";

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

type Step = { title: string; badge: string; description: string; icon: "inbox" | "mail" | "reply"; code: string[] };

const defaultSteps: Step[] = [
  { title: "Create a mailbox", badge: "POST", icon: "inbox", description: "Provision a dedicated address for your product and begin collecting messages with a single request.", code: ["import { Acme } from 'acme';", "", "const acme = new Acme('ak_xxxxxxxx');", "", "const { data, error } = await acme.mailboxes.create({", "  address: 'help@example.com',", "  label: 'Help Desk',", "  sender: 'Sam from Help',", "});"] },
  { title: "Fetch messages", badge: "GET", icon: "mail", description: "Pull incoming messages into your app and keep them in sync.", code: ["const { data } = await acme.messages.list({", "  mailbox: 'help@example.com',", "  limit: 20,", "});"] },
  { title: "Answer conversations", badge: "POST", icon: "reply", description: "Respond inside an existing thread so replies stay grouped.", code: ["await acme.threads.reply({", "  threadId: 'th_123',", "  text: 'Thanks, on it!',", "});"] },
];

function Icon({ k }: { k: Step["icon"] }) {
  const p = { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round" as const, strokeLinejoin: "round" as const };
  if (k === "inbox") return <svg {...p}><path d="M22 12h-6l-2 3h-4l-2-3H2" /><path d="M5 5h14l3 7v7H2v-7z" /></svg>;
  if (k === "mail") return <svg {...p}><rect x="3" y="5" width="18" height="14" rx="3" /><path d="m4 8 8 5 8-5" /></svg>;
  return <svg {...p}><path d="M9 14 4 9l5-5" /><path d="M4 9h10a6 6 0 0 1 6 6v3" /></svg>;
}

export default function ApiStepAccordion({ eyebrow = "API-First", titleTop = "Ship mailboxes", titleBottom = "on your terms", subtitle = "Create mailboxes from code, receive messages, and manage threads through one simple API.", steps = defaultSteps }: { eyebrow?: string; titleTop?: string; titleBottom?: string; subtitle?: string; steps?: Step[] }) {
  const [active, setActive] = useState(0);
  const [lang, setLang] = useState("Node.js");
  const current = steps[active];
  return (
    <section className="relative isolate overflow-hidden bg-background px-4 py-20 text-primary">
      <div aria-hidden className="absolute inset-0 -z-10 bg-[radial-gradient(var(--color-hairline)_1px,transparent_1px)] [background-size:16px_16px] [mask-image:radial-gradient(circle,transparent_0%,black_100%)]" />
      <Reveal className="mx-auto max-w-2xl text-center">
        <p className="inline-flex items-center gap-2 font-mono text-caption text-secondary"><span className="inline-block h-3 w-3 rounded-sm border border-secondary" />{eyebrow}</p>
        <h2 className="mt-4 bg-silver-text bg-clip-text font-serif text-5xl leading-[1.05] tracking-[-0.03em] text-transparent md:text-6xl">{titleTop}<br />{titleBottom}</h2>
        <p className="mx-auto mt-6 max-w-lg text-lead text-secondary">{subtitle}</p>
      </Reveal>
      <div className="mx-auto mt-16 grid max-w-5xl gap-4 lg:grid-cols-[440px_1fr]">
        <div className="flex flex-col gap-3">
          {steps.map((s, i) => {
            const on = i === active;
            return (
              <button key={s.title} onClick={() => setActive(i)} aria-expanded={on} className={`rounded-xl border p-[1px] text-left transition-colors duration-hover-color focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent-blue ${on ? "border-accent-blue/50 bg-surface shadow-glow-blue" : "border-hairline bg-background hover:bg-surface"}`}>
                <div className="p-6">
                  <div className="flex items-center gap-3">
                    <span className={`flex h-10 w-10 items-center justify-center rounded-lg border border-hairline bg-background ${on ? "text-accent-blue" : "text-primary"}`}><Icon k={s.icon} /></span>
                    <span className="flex-1 text-lg font-medium">{s.title}</span>
                    {on && <span className="rounded-pill border border-hairline px-3 py-1 font-mono text-[11px] font-semibold tracking-wider text-accent-blue animate-[fadein_400ms_300ms_both]">{s.badge}</span>}
                  </div>
                  {on && <p className="mt-5 text-sm leading-6 text-secondary animate-[fadein_300ms_both]">{s.description}</p>}
                </div>
              </button>
            );
          })}
        </div>
        <div className="min-h-[375px] rounded-xl border border-hairline bg-surface/60 p-4">
          <div className="flex items-center justify-between">
            <div className="flex gap-2">{[0, 1, 2].map((n) => <span key={n} className="h-2.5 w-2.5 rounded-full border border-muted" />)}</div>
            <div className="flex items-center gap-4 text-sm text-secondary">
              <select aria-label="Language" value={lang} onChange={(e) => setLang(e.target.value)} className="bg-transparent text-secondary focus-visible:outline focus-visible:outline-accent-blue">
                <option className="bg-surface">Node.js</option>
                <option className="bg-surface">Python</option>
              </select>
              <button aria-label="Copy code" onClick={() => navigator.clipboard?.writeText(current.code.join("\n"))} className="hover:text-primary"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><rect x="9" y="9" width="11" height="11" rx="2" /><path d="M5 15V6a2 2 0 0 1 2-2h9" /></svg></button>
            </div>
          </div>
          <pre className="mt-10 overflow-x-auto font-mono text-[13px] leading-5 text-primary"><code>{current.code.map((l, i) => <div key={i} className="min-h-5 whitespace-pre">{l}</div>)}</code></pre>
        </div>
      </div>
      <style>{`@keyframes fadein{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){*{animation:none!important}}`}</style>
    </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 · 5d ago
—

More from Obsidian Serif Glow

The whole style →

Blue Glass Agent Config Card

Forms

Hairline Use-Case Grid

Feature sections

Serif Hero with Dark 3D Object

Heroes

Monochrome Logo Cloud

Logo clouds

Language Picker and Code Window

Code blocks

Glossy Icon Section Header

Feature sections