Page sections / Stats & metrics
Hairline Stat Row with Sunburst
A centered headline above four-column KPI cells split by hairline rules. Numbers are large light-weight navy and fade to slate. Below sits a huge blue fiber-optic canvas sunburst over a soft blue radial glow, with a small theme toggle chip in the corner.
Rebuilt from stripe.com in the Iridescent Ledger style.
Looks exactly like stripe.com: brings its fonts and colours, namespaced so your own theme stays untouched.
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
Usage
Props: `heading` (use \n for line breaks) and `stats` (array of {to, decimals, prefix, suffix, label, faded}). Numbers count up on scroll; the sunburst animates outward on load and the corner chip toggles a dark theme.
components/stat-ribbon.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useMemo, useState } from "react"; type Stat = { to: number; decimals?: number; prefix?: string; suffix?: string; label: string; faded?: boolean }; export default function HairlineStatRowWithSunburst({ heading = "The foundation of\nmodern global trade", stats = [ { to: 120, suffix: "+", label: "currencies and payment\nmethods supported" }, { to: 2.4, decimals: 1, prefix: "$", suffix: "T", label: "in transactions volume\nhandled in 2025", faded: true }, { to: 99.99, decimals: 2, suffix: "%", label: "measured uptime\nacross core services", faded: true }, { to: 150, suffix: "M+", label: "active accounts\nmanaged on the platform", faded: true }, ] as Stat[], }: { heading?: string; stats?: Stat[]; }) { const [dark, setDark] = useState(false); const rays = useMemo(() => { const out: { x: number; y: number; w: number; o: number; c: string }[] = []; let s = 7; const r = () => ((s = (s * 9301 + 49297) % 233280) / 233280); for (let i = 0; i < 260; i++) { const a = Math.PI + r() * Math.PI; const len = 120 + r() * 300; out.push({ x: 600 + Math.cos(a) * len, y: 520 + Math.sin(a) * len, w: 0.5 + r() * 1.2, o: 0.3 + r() * 0.7, c: r() > 0.5 ? "#2f4fe0" : "#4aa3f5" }); } return out; }, []); return ( <section className={`relative mx-auto w-full max-w-[1266px] overflow-hidden border-x border-hairline ${dark ? "bg-night text-surface" : "bg-canvas text-ink"}`}> <style>{`@keyframes fiberOut{from{transform:scale(.2);opacity:0}to{transform:scale(1);opacity:1}}.fiber{transform-origin:600px 520px;animation:fiberOut 2.4s cubic-bezier(.19,1,.22,1) both}@media(prefers-reduced-motion:reduce){.fiber{animation:none}}`}</style> <Reveal from="up" className="px-6 py-16 text-center md:py-20"> <h2 className="mx-auto whitespace-pre-line font-display text-h1 font-light tracking-[-0.02em] text-ink-deep">{heading}</h2> </Reveal> <Stagger step={100} className="grid grid-cols-2 border-y border-hairline md:grid-cols-4"> {stats.map((s, i) => ( <div key={i} className={`px-4 py-10 text-center ${i > 0 ? "md:border-l md:border-hairline" : ""}`}> <div className={`font-display text-[40px] font-light leading-none tracking-[-0.03em] md:text-[52px] ${s.faded ? "text-ink-faint" : "text-ink-deep"}`}> <CountUp to={s.to} decimals={s.decimals ?? 0} prefix={s.prefix ?? ""} suffix={s.suffix ?? ""} /> </div> <p className={`mt-4 whitespace-pre-line text-ui ${s.faded ? "text-ink-faint" : "text-ink"}`}>{s.label}</p> </div> ))} </Stagger> <div className="relative h-[420px] md:h-[520px]"> <div className="absolute inset-0 bg-[radial-gradient(75%_100%_at_50%_105%,#4a8ff7_0%,#a9cffc_40%,transparent_75%)]" /> <button type="button" aria-label="Toggle theme" aria-pressed={dark} onClick={() => setDark(!dark)} className="absolute right-4 top-6 z-10 grid h-8 w-8 place-items-center rounded-sm border border-hairline bg-accent-wash text-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent" > <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round"><circle cx="8" cy="8" r="3" /><path d="M8 1v2M8 13v2M1 8h2M13 8h2M3 3l1.4 1.4M11.6 11.6L13 13M13 3l-1.4 1.4M4.4 11.6L3 13" /></svg> </button> <svg viewBox="0 0 1200 520" preserveAspectRatio="xMidYMax slice" className="absolute inset-0 h-full w-full" aria-hidden="true"> <g className="fiber"> {rays.map((l, i) => ( <g key={i} opacity={l.o}> <line x1="600" y1="520" x2={l.x} y2={l.y} stroke={l.c} strokeWidth={l.w} /> <circle cx={l.x} cy={l.y} r={l.w + 0.8} fill={l.c} /> </g> ))} </g> </svg> </div> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Stagger, CountUp ---- 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; } const ykSrOnly: CSSProperties = { position: "absolute", width: 1, height: 1, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap", border: 0 }; // "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> ); } /** Reveals each direct child one after another when the group scrolls into view. */ function Stagger({ children, step = 90, from = "up", distance = 20, duration = 650, delay = 0, once = true, as = "div", className, style, }: { children?: ReactNode; step?: number; from?: "up" | "down" | "left" | "right" | "scale" | "fade"; distance?: number; duration?: number; delay?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); useYkLayoutEffect(() => { const items = Array.from(ref.current?.children ?? []) as HTMLElement[]; if (state === "idle") return; 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.92)", fade: "none", }[from]; if (state === "hidden") { for (const el of items) Object.assign(el.style, { transition: "none", opacity: "0", transform: offset }); return; } items.forEach((el, i) => { const t = `${duration}ms ${YK_EASE} ${delay + i * step}ms`; Object.assign(el.style, { transition: `opacity ${t}, transform ${t}`, opacity: "", transform: "" }); }); // hand the children their own transitions back once everything has landed const done = setTimeout(() => items.forEach((el) => (el.style.transition = "")), delay + items.length * step + duration + 50); return () => clearTimeout(done); }, [state]); return ( <Tag ref={ref} className={className} style={style}> {children} </Tag> ); } /** A number that counts up when it scrolls into view. */ function CountUp({ to = 100, from = 0, duration = 1800, decimals = 0, prefix = "", suffix = "", locale, className, style, }: { to?: number; from?: number; duration?: number; decimals?: number; prefix?: string; suffix?: string; locale?: string; className?: string; style?: CSSProperties; }) { const ref = useRef<HTMLSpanElement>(null); const state = useYkReveal(ref); const [value, setValue] = useState(to); const fmt = (n: number) => `${prefix}${n.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals })}${suffix}`; useYkLayoutEffect(() => { if (state === "hidden") setValue(from); }, [state]); useEffect(() => { if (state !== "shown") return; let raf = 0; const start = performance.now(); const tick = (now: number) => { const p = Math.min(1, (now - start) / duration); const eased = p === 1 ? 1 : 1 - Math.pow(2, -10 * p); setValue(from + (to - from) * eased); if (p < 1) raf = requestAnimationFrame(tick); }; raf = requestAnimationFrame(tick); return () => cancelAnimationFrame(raf); }, [state, to, from, duration]); return ( <span ref={ref} className={className} style={{ fontVariantNumeric: "tabular-nums", ...style }}> <span aria-hidden="true">{fmt(value)}</span> <span style={ykSrOnly}>{fmt(to)}</span> </span> ); }"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useMemo, useState } from "react"; type Stat = { to: number; decimals?: number; prefix?: string; suffix?: string; label: string; faded?: boolean }; export default function HairlineStatRowWithSunburst({ heading = "The foundation of\nmodern global trade", stats = [ { to: 120, suffix: "+", label: "currencies and payment\nmethods supported" }, { to: 2.4, decimals: 1, prefix: "$", suffix: "T", label: "in transactions volume\nhandled in 2025", faded: true }, { to: 99.99, decimals: 2, suffix: "%", label: "measured uptime\nacross core services", faded: true }, { to: 150, suffix: "M+", label: "active accounts\nmanaged on the platform", faded: true }, ] as Stat[], }: { heading?: string; stats?: Stat[]; }) { const [dark, setDark] = useState(false); const rays = useMemo(() => { const out: { x: number; y: number; w: number; o: number; c: string }[] = []; let s = 7; const r = () => ((s = (s * 9301 + 49297) % 233280) / 233280); for (let i = 0; i < 260; i++) { const a = Math.PI + r() * Math.PI; const len = 120 + r() * 300; out.push({ x: 600 + Math.cos(a) * len, y: 520 + Math.sin(a) * len, w: 0.5 + r() * 1.2, o: 0.3 + r() * 0.7, c: r() > 0.5 ? "#2f4fe0" : "#4aa3f5" }); } return out; }, []); return ( <section className={`relative mx-auto w-full max-w-[1266px] overflow-hidden border-x border-border ${dark ? "bg-foreground text-card" : "bg-background text-foreground"}`}> <style>{`@keyframes fiberOut{from{transform:scale(.2);opacity:0}to{transform:scale(1);opacity:1}}.fiber{transform-origin:600px 520px;animation:fiberOut 2.4s cubic-bezier(.19,1,.22,1) both}@media(prefers-reduced-motion:reduce){.fiber{animation:none}}`}</style> <Reveal from="up" className="px-6 py-16 text-center md:py-20"> <h2 className="mx-auto whitespace-pre-line font-sans text-iridescent-h1 font-light tracking-[-0.02em] text-muted-foreground">{heading}</h2> </Reveal> <Stagger step={100} className="grid grid-cols-2 border-y border-border md:grid-cols-4"> {stats.map((s, i) => ( <div key={i} className={`px-4 py-10 text-center ${i > 0 ? "md:border-l md:border-border" : ""}`}> <div className={`font-sans text-[40px] font-light leading-none tracking-[-0.03em] md:text-[52px] ${s.faded ? "text-muted-foreground" : "text-muted-foreground"}`}> <CountUp to={s.to} decimals={s.decimals ?? 0} prefix={s.prefix ?? ""} suffix={s.suffix ?? ""} /> </div> <p className={`mt-4 whitespace-pre-line text-iridescent-ui ${s.faded ? "text-muted-foreground" : "text-foreground"}`}>{s.label}</p> </div> ))} </Stagger> <div className="relative h-[420px] md:h-[520px]"> <div className="absolute inset-0 bg-[radial-gradient(75%_100%_at_50%_105%,#4a8ff7_0%,#a9cffc_40%,transparent_75%)]" /> <button type="button" aria-label="Toggle theme" aria-pressed={dark} onClick={() => setDark(!dark)} className="absolute right-4 top-6 z-10 grid h-8 w-8 place-items-center rounded-sm border border-border bg-primary/10 text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary" > <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round"><circle cx="8" cy="8" r="3" /><path d="M8 1v2M8 13v2M1 8h2M13 8h2M3 3l1.4 1.4M11.6 11.6L13 13M13 3l-1.4 1.4M4.4 11.6L3 13" /></svg> </button> <svg viewBox="0 0 1200 520" preserveAspectRatio="xMidYMax slice" className="absolute inset-0 h-full w-full" aria-hidden="true"> <g className="fiber"> {rays.map((l, i) => ( <g key={i} opacity={l.o}> <line x1="600" y1="520" x2={l.x} y2={l.y} stroke={l.c} strokeWidth={l.w} /> <circle cx={l.x} cy={l.y} r={l.w + 0.8} fill={l.c} /> </g> ))} </g> </svg> </div> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Stagger, CountUp ---- 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; } const ykSrOnly: CSSProperties = { position: "absolute", width: 1, height: 1, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap", border: 0 }; // "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> ); } /** Reveals each direct child one after another when the group scrolls into view. */ function Stagger({ children, step = 90, from = "up", distance = 20, duration = 650, delay = 0, once = true, as = "div", className, style, }: { children?: ReactNode; step?: number; from?: "up" | "down" | "left" | "right" | "scale" | "fade"; distance?: number; duration?: number; delay?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); useYkLayoutEffect(() => { const items = Array.from(ref.current?.children ?? []) as HTMLElement[]; if (state === "idle") return; 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.92)", fade: "none", }[from]; if (state === "hidden") { for (const el of items) Object.assign(el.style, { transition: "none", opacity: "0", transform: offset }); return; } items.forEach((el, i) => { const t = `${duration}ms ${YK_EASE} ${delay + i * step}ms`; Object.assign(el.style, { transition: `opacity ${t}, transform ${t}`, opacity: "", transform: "" }); }); // hand the children their own transitions back once everything has landed const done = setTimeout(() => items.forEach((el) => (el.style.transition = "")), delay + items.length * step + duration + 50); return () => clearTimeout(done); }, [state]); return ( <Tag ref={ref} className={className} style={style}> {children} </Tag> ); } /** A number that counts up when it scrolls into view. */ function CountUp({ to = 100, from = 0, duration = 1800, decimals = 0, prefix = "", suffix = "", locale, className, style, }: { to?: number; from?: number; duration?: number; decimals?: number; prefix?: string; suffix?: string; locale?: string; className?: string; style?: CSSProperties; }) { const ref = useRef<HTMLSpanElement>(null); const state = useYkReveal(ref); const [value, setValue] = useState(to); const fmt = (n: number) => `${prefix}${n.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals })}${suffix}`; useYkLayoutEffect(() => { if (state === "hidden") setValue(from); }, [state]); useEffect(() => { if (state !== "shown") return; let raf = 0; const start = performance.now(); const tick = (now: number) => { const p = Math.min(1, (now - start) / duration); const eased = p === 1 ? 1 : 1 - Math.pow(2, -10 * p); setValue(from + (to - from) * eased); if (p < 1) raf = requestAnimationFrame(tick); }; raf = requestAnimationFrame(tick); return () => cancelAnimationFrame(raf); }, [state, to, from, duration]); return ( <span ref={ref} className={className} style={{ fontVariantNumeric: "tabular-nums", ...style }}> <span aria-hidden="true">{fmt(value)}</span> <span style={ykSrOnly}>{fmt(to)}</span> </span> ); }
Quality checks
Automated, in a real browser · 5d ago- Accessible: passedNo serious accessibility problems (axe-core): readable contrast, labelled buttons and images.
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: passedStill readable when installed in your theme and switched to dark mode.
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: passedIts animation plays and finishes with everything visible, and it stays still for people who turn on reduced motion.