Page sections / Feature sections
Accordion Feature List with Product Mock
Left column headline above a hairline-separated list: the active item has a glowing blue dot, bold title and expanded description, others are muted single lines; right side shows a floating dark app-window mockup of an accounts list with edge-faded cropping and a cursor.
Rebuilt from mercury.com in the Twilight Ledger style.
Looks exactly like mercury.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, items (title, body, note, rows), ctaLabel, ctaHref. Click a list item to expand it and swap the mock account panel with a blur crossfade.
components/tabbed-feature-list.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; type Item = { title: string; body: string; rows: { name: string; amt: string; cents: string }[]; note: string }; const DEFAULT_ITEMS: Item[] = [ { title: "Inventory tracking & more", body: "Monitor stock across every warehouse in real time, set smart reorder thresholds, and forecast demand with Northwind Insights.", note: "4 reorder alerts need your attention", rows: [{ name: "Main Warehouse", amt: "$48,210", cents: "40" }, { name: "East Depot", amt: "$32,900", cents: "15" }, { name: "Returns", amt: "$8,744", cents: "60" }, { name: "In Transit", amt: "$19,320", cents: "05" }, { name: "Showroom", amt: "$2,118", cents: "90" }] }, { title: "Shipping & fulfillment", body: "Compare carriers, print labels in bulk and follow every parcel until it lands.", note: "2 shipments are delayed today", rows: [{ name: "Pending Labels", amt: "$1,240", cents: "00" }, { name: "Picked Up", amt: "$6,810", cents: "25" }, { name: "In Flight", amt: "$14,450", cents: "70" }, { name: "Delivered", amt: "$92,030", cents: "10" }, { name: "Exceptions", amt: "$310", cents: "45" }] }, { title: "Supplier relations", body: "Keep contracts, quotes and contacts together.", note: "1 contract renews this week", rows: [{ name: "Alder Mills", amt: "$12,000", cents: "00" }, { name: "Kitefield Co.", amt: "$7,450", cents: "20" }, { name: "Lumen Supply", amt: "$3,980", cents: "75" }, { name: "Altura Goods", amt: "$21,600", cents: "30" }, { name: "Harbor Parts", amt: "$940", cents: "55" }] }, { title: "Reporting", body: "Dashboards and exports.", note: "3 scheduled reports are ready", rows: [{ name: "Weekly Summary", amt: "$0", cents: "00" }, { name: "Margin Review", amt: "$0", cents: "00" }, { name: "Stock Aging", amt: "$0", cents: "00" }, { name: "Forecast", amt: "$0", cents: "00" }, { name: "Audit Log", amt: "$0", cents: "00" }] }, ]; export default function AccordionFeatureListWithProductMock({ heading = "Every shipment you track.\nAll in one view.", items = DEFAULT_ITEMS, ctaLabel = "Launch demo", ctaHref = "#" }: { heading?: string; items?: Item[]; ctaLabel?: string; ctaHref?: string }) { const [active, setActive] = useState(0); const cur = items[active]; return ( <section className="relative overflow-hidden bg-canvas text-ink font-sans"> <div className="mx-auto grid max-w-[1440px] items-center gap-12 px-6 py-24 lg:grid-cols-2 lg:px-[152px] lg:py-40"> <Reveal from="up" distance={20}> <h2 className="whitespace-pre-line text-h2 text-ink">{heading}</h2> <div className="mt-[60px] max-w-[464px]"> {items.map((it, i) => { const open = i === active; return ( <div key={it.title} className="relative border-t border-hairline"> {open && <span className="absolute -left-5 top-[18px] h-2 w-2 rounded-pill bg-accent shadow-glow-soft" />} <button onClick={() => setActive(i)} aria-expanded={open} className={`block w-full py-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-accent transition-colors duration-hover-wash ease-hover-wash ${open ? "text-ink font-medium" : "text-ink-subtle hover:text-ink"}`}> {it.title} </button> <div className={`grid transition-[grid-template-rows] duration-300 ${open ? "grid-rows-[1fr]" : "grid-rows-[0fr]"}`}> <div className="overflow-hidden"><p className="pb-5 text-body text-ink-muted">{it.body}</p></div> </div> </div> ); })} </div> <a href={ctaHref} className="mt-10 inline-block underline underline-offset-4 focus-visible:ring-2 focus-visible:ring-accent">{ctaLabel}</a> </Reveal> <div className="relative rounded-xl bg-surface-deep p-8 shadow-float lg:[mask-image:linear-gradient(to_right,#000_60%,transparent)]"> <div key={active} className="animate-blur-swap rounded-lg border border-hairline bg-surface shadow-card-lift"> <div className="flex items-center justify-between px-6 py-5 text-ink-muted"> <span>Overview</span> <span className="flex h-8 w-8 items-center justify-center rounded-pill bg-glass-fill">+</span> </div> <ul className="space-y-4 px-6 pb-5"> {cur.rows.map((r, i) => ( <li key={r.name} className="flex items-center justify-between text-ink-muted"> <span className="flex items-center gap-3"> <span className="h-7 w-7 rounded-pill border border-ink-subtle bg-[radial-gradient(circle,var(--color-hairline),transparent)]" /> {r.name} </span> <span>{r.amt}<sup className="text-caption text-ink-subtle">.{r.cents}</sup></span> </li> ))} </ul> <div className="relative flex items-center justify-between border-t border-hairline px-6 py-5 text-ink-muted"> <span className="flex items-center gap-3"><span className="h-2 w-4 rounded-pill bg-accent" />{cur.note}</span> <span className="text-accent-tint">View ›</span> <svg className="absolute right-6 top-10 h-5 w-5 text-ink" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path d="M4 1l11 8-5 1 3 6-2 1-3-6-4 3z" /></svg> </div> </div> <div className="mt-6 grid grid-cols-2 gap-6"> <div className="h-24 rounded-lg bg-surface/60" /> <div className="h-24 rounded-lg bg-surface/60" /> </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> ); }"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; type Item = { title: string; body: string; rows: { name: string; amt: string; cents: string }[]; note: string }; const DEFAULT_ITEMS: Item[] = [ { title: "Inventory tracking & more", body: "Monitor stock across every warehouse in real time, set smart reorder thresholds, and forecast demand with Northwind Insights.", note: "4 reorder alerts need your attention", rows: [{ name: "Main Warehouse", amt: "$48,210", cents: "40" }, { name: "East Depot", amt: "$32,900", cents: "15" }, { name: "Returns", amt: "$8,744", cents: "60" }, { name: "In Transit", amt: "$19,320", cents: "05" }, { name: "Showroom", amt: "$2,118", cents: "90" }] }, { title: "Shipping & fulfillment", body: "Compare carriers, print labels in bulk and follow every parcel until it lands.", note: "2 shipments are delayed today", rows: [{ name: "Pending Labels", amt: "$1,240", cents: "00" }, { name: "Picked Up", amt: "$6,810", cents: "25" }, { name: "In Flight", amt: "$14,450", cents: "70" }, { name: "Delivered", amt: "$92,030", cents: "10" }, { name: "Exceptions", amt: "$310", cents: "45" }] }, { title: "Supplier relations", body: "Keep contracts, quotes and contacts together.", note: "1 contract renews this week", rows: [{ name: "Alder Mills", amt: "$12,000", cents: "00" }, { name: "Kitefield Co.", amt: "$7,450", cents: "20" }, { name: "Lumen Supply", amt: "$3,980", cents: "75" }, { name: "Altura Goods", amt: "$21,600", cents: "30" }, { name: "Harbor Parts", amt: "$940", cents: "55" }] }, { title: "Reporting", body: "Dashboards and exports.", note: "3 scheduled reports are ready", rows: [{ name: "Weekly Summary", amt: "$0", cents: "00" }, { name: "Margin Review", amt: "$0", cents: "00" }, { name: "Stock Aging", amt: "$0", cents: "00" }, { name: "Forecast", amt: "$0", cents: "00" }, { name: "Audit Log", amt: "$0", cents: "00" }] }, ]; export default function AccordionFeatureListWithProductMock({ heading = "Every shipment you track.\nAll in one view.", items = DEFAULT_ITEMS, ctaLabel = "Launch demo", ctaHref = "#" }: { heading?: string; items?: Item[]; ctaLabel?: string; ctaHref?: string }) { const [active, setActive] = useState(0); const cur = items[active]; return ( <section className="relative overflow-hidden bg-background text-foreground font-sans"> <div className="mx-auto grid max-w-[1440px] items-center gap-12 px-6 py-24 lg:grid-cols-2 lg:px-[152px] lg:py-40"> <Reveal from="up" distance={20}> <h2 className="whitespace-pre-line text-twilight-h2 text-foreground">{heading}</h2> <div className="mt-[60px] max-w-[464px]"> {items.map((it, i) => { const open = i === active; return ( <div key={it.title} className="relative border-t border-border"> {open && <span className="absolute -left-5 top-[18px] h-2 w-2 rounded-full bg-primary shadow-twilight-glow-soft" />} <button onClick={() => setActive(i)} aria-expanded={open} className={`block w-full py-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-primary transition-colors duration-twilight-hover-wash ease-twilight-hover-wash ${open ? "text-foreground font-medium" : "text-muted-foreground hover:text-foreground"}`}> {it.title} </button> <div className={`grid transition-[grid-template-rows] duration-300 ${open ? "grid-rows-[1fr]" : "grid-rows-[0fr]"}`}> <div className="overflow-hidden"><p className="pb-5 text-twilight-body text-muted-foreground">{it.body}</p></div> </div> </div> ); })} </div> <a href={ctaHref} className="mt-10 inline-block underline underline-offset-4 focus-visible:ring-2 focus-visible:ring-primary">{ctaLabel}</a> </Reveal> <div className="relative rounded-2xl bg-muted p-8 shadow-twilight-float lg:[mask-image:linear-gradient(to_right,#000_60%,transparent)]"> <div key={active} className="animate-twilight-blur-swap rounded-2xl border border-border bg-card shadow-twilight-card-lift"> <div className="flex items-center justify-between px-6 py-5 text-muted-foreground"> <span>Overview</span> <span className="flex h-8 w-8 items-center justify-center rounded-full bg-secondary">+</span> </div> <ul className="space-y-4 px-6 pb-5"> {cur.rows.map((r, i) => ( <li key={r.name} className="flex items-center justify-between text-muted-foreground"> <span className="flex items-center gap-3"> <span className="h-7 w-7 rounded-full border border-muted-foreground bg-[radial-gradient(circle,var(--color-border),transparent)]" /> {r.name} </span> <span>{r.amt}<sup className="text-twilight-caption text-muted-foreground">.{r.cents}</sup></span> </li> ))} </ul> <div className="relative flex items-center justify-between border-t border-border px-6 py-5 text-muted-foreground"> <span className="flex items-center gap-3"><span className="h-2 w-4 rounded-full bg-primary" />{cur.note}</span> <span className="text-primary/10">View ›</span> <svg className="absolute right-6 top-10 h-5 w-5 text-foreground" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path d="M4 1l11 8-5 1 3 6-2 1-3-6-4 3z" /></svg> </div> </div> <div className="mt-6 grid grid-cols-2 gap-6"> <div className="h-24 rounded-2xl bg-card/60" /> <div className="h-24 rounded-2xl bg-card/60" /> </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 · 4d ago- Accessible: not passedElements must meet minimum color contrast ratio thresholds (3 elements)
- 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: not passedStays invisible after its animation: <div> "Overview"