Cards & content / Code blocks

Language Picker and Code Window

Row of 56px rounded-square icon tiles with labels (active tile has a bright outline and orange icon) above a rounded hairline code panel. The panel has a framework tab strip, copy button, line-numbered mono code with orange strings and gray keywords, and a footer of GitHub/ZIP links. A glossy 3D app-icon sits above a gradient headline with an orange highlighted phrase.

Rebuilt from resend.com in the Obsidian Serif Glow style.

npx shadcn@latest add https://justyoink.it/r/obsidian-serif-glow/blocks/language-picker-code-window.json

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

Usage

Renders standalone; optional props title, highlight and description change the headline copy. Clicking a language tile or a framework tab swaps the code, which slides in from above over about 340ms.

components/language-picker-code-window.tsx
"use client";

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

type Lang = { id: string; label: string; glyph: string; tabs: string[]; lines: string[] };

const mk = (client: string, pkg: string, sender: string): string[] => [
  `import { ${client} } from '${pkg}';`,
  ``,
  `const mailer = new ${client}('key_xxxxxxxx');`,
  ``,
  `(async function() {`,
  `  const { data, error } = await mailer.messages.send({`,
  `    from: '${sender}@northwind.test',`,
  `    to: 'inbox@northwind.test',`,
  `    subject: 'Hello there',`,
  `    html: '<p>it works</p>'`,
  `  });`,
  ``,
  `  if (error) {`,
  `    return console.log(error);`,
  `  }`,
  ``,
  `  console.log(data);`,
  `})();`,
];

const LANGS: Lang[] = [
  { id: "node", label: "Node.js", glyph: "JS", tabs: ["Node.js", "Next.js", "Remix", "Nuxt", "Express", "Hono", "Bun", "Astro"], lines: mk("Mailer", "mailer", "hello") },
  { id: "srv", label: "Serverless", glyph: "ϟ", tabs: ["Lambda", "Edge", "Workers"], lines: mk("Mailer", "mailer/edge", "edge") },
  { id: "rb", label: "Ruby", glyph: "◆", tabs: ["Rails", "Sinatra"], lines: mk("Mailer", "mailer-rb", "ruby") },
  { id: "py", label: "Python", glyph: "Py", tabs: ["Django", "Flask", "FastAPI"], lines: mk("Mailer", "mailer_py", "py") },
  { id: "php", label: "PHP", glyph: "php", tabs: ["Laravel", "Symfony"], lines: mk("Mailer", "mailer/php", "php") },
  { id: "cli", label: "CLI", glyph: ">_", tabs: ["Shell"], lines: mk("Mailer", "mailer-cli", "cli") },
  { id: "go", label: "Go", glyph: "GO", tabs: ["Standard", "Gin"], lines: mk("Mailer", "mailer-go", "go") },
  { id: "rs", label: "Rust", glyph: "Rs", tabs: ["Tokio", "Axum"], lines: mk("Mailer", "mailer-rs", "rust") },
  { id: "java", label: "Java", glyph: "Jv", tabs: ["Spring", "Plain"], lines: mk("Mailer", "mailer-java", "java") },
  { id: "ex", label: "Elixir", glyph: "Ex", tabs: ["Phoenix"], lines: mk("Mailer", "mailer_ex", "ex") },
  { id: "net", label: ".NET", glyph: ".NET", tabs: ["ASP.NET", "Console"], lines: mk("Mailer", "Mailer.Net", "net") },
  { id: "rest", label: "REST", glyph: "{ }", tabs: ["cURL", "HTTP"], lines: mk("Mailer", "rest", "api") },
  { id: "smtp", label: "SMTP", glyph: "SMTP", tabs: ["Relay"], lines: mk("Mailer", "smtp", "smtp") },
];

function Line({ text }: { text: string }) {
  const parts = text.split(/('[^']*')/g);
  return (
    <>
      {parts.map((p, i) =>
        p.startsWith("'") ? (
          <span key={i} className="text-accent-orange">{p}</span>
        ) : (
          <span key={i}>
            {p.split(/\b(import|from|const|new|async|function|await|if|return)\b/g).map((q, j) =>
              /^(import|from|const|new|async|function|await|if|return)$/.test(q) ? (
                <span key={j} className="text-muted">{q}</span>
              ) : (
                q
              )
            )}
          </span>
        )
      )}
    </>
  );
}

export default function LanguagePickerCodeWindow({
  title = "Integrate",
  highlight = "this afternoon",
  description = "A clean, friendly interface so you can begin delivering messages in minutes. It slots into your codebase with libraries for the languages you already use.",
}: {
  title?: string;
  highlight?: string;
  description?: string;
}) {
  const [langId, setLangId] = useState("node");
  const [tab, setTab] = useState(0);
  const [key, setKey] = useState(0);
  const lang = LANGS.find((l) => l.id === langId)!;

  const pickLang = (id: string) => {
    setLangId(id);
    setTab(0);
    setKey((k) => k + 1);
  };
  const pickTab = (i: number) => {
    setTab(i);
    setKey((k) => k + 1);
  };

  return (
    <section className="bg-background text-primary px-4 py-20 font-sans">
      <style>{`@keyframes codeSlideIn{from{transform:translateY(-40px);opacity:0}to{transform:none;opacity:1}}`}</style>
      <div className="mx-auto flex max-w-[1024px] flex-col items-center">
        <Reveal from="scale">
          <div className="relative h-[146px] w-[146px] rounded-[34px] border border-hairline bg-[linear-gradient(160deg,#2a2a2a,#0a0a0a_60%)] shadow-[0_8px_30px_-6px_rgba(255,140,40,0.35)] flex items-center justify-center">
            <div className="h-[66px] w-[96px] rounded-xl border border-white/20 bg-[linear-gradient(180deg,#3a2f26,#120d0a)] flex items-start justify-center overflow-hidden shadow-inset-highlight">
              <svg viewBox="0 0 96 66" className="h-full w-full" fill="none" stroke="rgba(255,255,255,0.45)" strokeWidth="2"><path d="M4 8l44 30L92 8" /></svg>
            </div>
          </div>
        </Reveal>

        <h2 className="mt-8 text-center font-display text-[44px] sm:text-[56px] leading-none tracking-[-0.03em]">
          <span className="bg-silver-text bg-clip-text text-transparent">{title}</span>{" "}
          <span className="bg-gradient-to-r from-accent-orange to-[#ffb35c] bg-clip-text text-transparent">{highlight}</span>
        </h2>
        <p className="mt-5 max-w-[640px] text-center text-lead text-secondary">{description}</p>

        <div className="mt-12 w-full overflow-x-auto">
          <div role="tablist" aria-label="Languages" className="mx-auto flex w-max gap-[16px] px-2">
            {LANGS.map((l) => {
              const active = l.id === langId;
              return (
                <button
                  key={l.id}
                  role="tab"
                  aria-selected={active}
                  onClick={() => pickLang(l.id)}
                  className="group flex w-[60px] flex-col items-center gap-3 outline-none"
                >
                  <span
                    className={`flex h-14 w-14 items-center justify-center rounded-xl border bg-background font-mono text-[13px] transition-colors duration-hover-color group-focus-visible:ring-2 group-focus-visible:ring-secondary ${
                      active ? "border-primary/70 text-accent-orange shadow-inset-highlight" : "border-hairline text-secondary group-hover:text-primary"
                    }`}
                  >
                    {l.glyph}
                  </span>
                  <span className={`text-ui whitespace-nowrap transition-colors duration-hover-color ${active ? "text-primary" : "text-secondary"}`}>{l.label}</span>
                </button>
              );
            })}
          </div>
        </div>

        <div className="relative mt-12 flex min-h-[597px] w-full flex-col overflow-hidden rounded-[28px] border border-hairline bg-background">
          <div className="flex items-center justify-between border-b border-hairline px-4 py-3">
            <div className="flex gap-1 overflow-x-auto">
              {lang.tabs.map((t, i) => (
                <button
                  key={t}
                  onClick={() => pickTab(i)}
                  className={`flex items-center gap-2 whitespace-nowrap rounded-md border px-2.5 py-1.5 text-ui outline-none transition-colors duration-hover-color focus-visible:ring-2 focus-visible:ring-secondary ${
                    i === tab ? "border-hairline bg-surface text-primary" : "border-transparent text-secondary hover:text-primary"
                  }`}
                >
                  <span className={`h-3.5 w-3.5 rounded-[4px] border ${i === tab ? "border-accent-orange" : "border-hairline"}`} />
                  {t}
                </button>
              ))}
            </div>
            <button aria-label="Copy code" onClick={() => navigator.clipboard?.writeText(lang.lines.join("\n"))} className="ml-3 flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-hairline text-secondary hover:text-primary outline-none focus-visible:ring-2 focus-visible:ring-secondary">
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><rect x="6" y="4" width="12" height="17" rx="2" /><path d="M9 4h6v3H9z" /></svg>
            </button>
          </div>

          <div className="flex-1 overflow-hidden">
            <pre key={key} style={{ animation: "codeSlideIn 340ms cubic-bezier(0.19,1,0.22,1)" }} className="overflow-x-auto px-4 py-6 font-mono text-[13px] leading-[20px] text-primary motion-reduce:!animate-none">
              {lang.lines.map((ln, i) => (
                <div key={i} className="flex">
                  <span className="w-8 shrink-0 select-none pr-4 text-right text-muted">{i + 1}</span>
                  <code className="whitespace-pre"><Line text={ln} /></code>
                </div>
              ))}
            </pre>
          </div>

          <div className="flex gap-6 px-5 py-5 text-caption text-secondary">
            <a href="#" className="flex items-center gap-2 hover:text-primary transition-colors duration-hover-color outline-none focus-visible:ring-2 focus-visible:ring-secondary rounded-sm">
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="9" /><path d="M9 20v-4M15 20v-4" /></svg>
              View on GitHub
            </a>
            <a href="#" className="flex items-center gap-2 hover:text-primary transition-colors duration-hover-color outline-none focus-visible:ring-2 focus-visible:ring-secondary rounded-sm">
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M12 4v11m-4-4l4 4 4-4M5 20h14" /></svg>
              Download ZIP
            </a>
          </div>
        </div>
      </div>
    </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

Glossy Icon Section Header

Feature sections

Test Mode and Webhook Dual Cards

Feature sections