Page sections / Feature sections
Hairline Bento Product Grid
Two-row bento of bordered white cards with a subtle top-down grey wash: one wide card and two narrow on top, four equal cards below. Each has an icon+title, a muted description with key phrases darkened, and a light line-art illustration at the bottom (elephant mark, scrolling email rows, wireframe globe, file tiles, cursor grid, isometric cube, API pill list). Ends with a large 'Use one or all.' two-tone tagline.
Rebuilt from supabase.com in the Emerald Paper Precision style.
Looks exactly like supabase.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
Optional props: tagline and taglineMuted set the two-tone closing line; card copy lives in the cards array. Rows drift on 30–35s linear loops and cards darken their border on hover.
components/bento-product-grid.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; type Card = { title: string; before: string; strong: string; after: string }; type Props = { tagline?: string; taglineMuted?: string; }; const Icon = () => ( <svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" strokeWidth="1.3" aria-hidden="true"> <rect x="3" y="3" width="12" height="12" rx="3" /> <path d="M6 9h6" /> </svg> ); const Desc = ({ c }: { c: Card }) => ( <p className="mt-4 text-body text-ink-muted"> {c.before} <span className="text-ink">{c.strong}</span> {c.after} </p> ); const shell = "group relative overflow-hidden rounded-xl border border-hairline bg-gradient-to-b from-ink/[0.04] to-ink/[0.02] bg-surface transition-colors duration-base-transition ease-base-transition hover:border-hairline-strong"; function Head({ c }: { c: Card }) { return ( <div className="p-6 pb-0"> <div className="flex items-center gap-2.5 font-display text-lead text-ink"> <span className="text-ink-soft"><Icon /></span> {c.title} </div> <Desc c={c} /> </div> ); } const cards: Card[] = [ { title: "Ledger Store", before: "Every workspace gets ", strong: "a durable relational store", after: ", tuned for steady reads and careful writes." }, { title: "Access", before: "", strong: "Invite teammates and set roles", after: ", keeping each record visible only to the right people." }, { title: "Workers", before: "Run small scripts near your data ", strong: "with no servers to babysit", after: "." }, { title: "Files", before: "", strong: "Keep, sort, and share", after: " documents, clips and scans in one place." }, { title: "Live Sync", before: "", strong: "Show who is online", after: " and keep shared boards in step as people edit." }, { title: "Search", before: "Index your notes and ", strong: "find similar items by meaning", after: " in milliseconds." }, { title: "Endpoints", before: "Ready-made ", strong: "HTTP endpoints", after: " for every table you create." }, ]; const emails = ["mira.t@example.com", "jon.park@example.com", "sol22@example.com", "kai.b@example.com", "ana.r@example.com"]; const routes = ["orders", "people", "teams", "invoices", "regions", "labels"]; export default function HairlineBentoProductGrid({ tagline = "Pick a piece or take the lot.", taglineMuted = "Simple parts that fit together as one workspace.", }: Props) { return ( <section className="bg-canvas px-4 py-16 text-ink sm:px-6"> <style>{`@keyframes hb-drift{from{transform:translateX(0)}to{transform:translateX(-50%)}}@media (prefers-reduced-motion:reduce){.hb-drift{animation:none!important}}`}</style> <div className="mx-auto max-w-[1088px]"> <Stagger step={70} from="up" className="grid gap-3 md:grid-cols-4"> <article className={`${shell} md:col-span-2 flex flex-col sm:flex-row min-h-[400px]`}> <div className="sm:w-1/2 flex flex-col justify-between pb-6"> <Head c={cards[0]} /> <ul className="px-6 space-y-1.5 text-body text-ink"> {["Fully portable", "Role rules built in", "Simple to extend"].map((t) => ( <li key={t} className="flex items-center gap-2"> <svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" strokeWidth="1.4"><path d="m2 7 3.5 3.5L12 3.5" /></svg> {t} </li> ))} </ul> </div> <div className="flex flex-1 items-center justify-center p-6"> <svg width="170" height="170" viewBox="0 0 170 170" fill="none" className="text-hairline-strong" aria-hidden="true"> <rect x="1" y="1" width="168" height="168" rx="14" stroke="currentColor" /> <circle cx="85" cy="85" r="52" stroke="currentColor" strokeWidth="6" /> <circle cx="85" cy="85" r="28" stroke="currentColor" strokeWidth="6" /> <circle cx="85" cy="85" r="6" fill="currentColor" /> </svg> </div> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[1]} /> <div className="absolute inset-x-0 bottom-8 overflow-hidden"> <div className="hb-drift flex w-max gap-3" style={{ animation: "hb-drift 35s linear infinite" }}> {[...emails, ...emails].map((e, i) => ( <div key={i} className={`flex h-14 w-56 items-center justify-center rounded-md border border-hairline bg-surface font-mono text-caption text-ink-soft ${i % 3 === 1 ? "blur-sm" : ""}`}>{e}</div> ))} </div> </div> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[2]} /> <div className="absolute left-1/2 top-[180px] -translate-x-1/2 whitespace-nowrap rounded-pill border border-hairline bg-surface px-3 py-2 font-mono text-caption"> <span className="text-ink-soft">$ ledger </span><span className="text-brand">workers push</span> </div> <svg viewBox="0 0 260 160" className="absolute inset-x-0 bottom-0 w-full text-hairline-strong" fill="none" stroke="currentColor" aria-hidden="true"> {[30, 60, 90, 120].map((r) => <ellipse key={r} cx="130" cy="170" rx={r * 2} ry={r * 1.3} />)} {[0, 1, 2, 3, 4, 5].map((i) => <path key={i} d={`M130 170 L${i * 52} 30`} />)} <circle cx="60" cy="90" r="3" fill="var(--color-ink)" /> <circle cx="215" cy="140" r="3" fill="var(--color-ink)" /> </svg> </article> <article className={`${shell} min-h-[400px] md:col-span-1`}> <Head c={cards[3]} /> <div className="absolute bottom-0 left-2 overflow-hidden right-0"> <div className="hb-drift flex w-max gap-3 pb-2" style={{ animation: "hb-drift 30s linear infinite reverse" }}> {[0, 1].map((k) => ( <div key={k} className="grid grid-flow-col grid-rows-3 gap-3"> {Array.from({ length: 18 }).map((_, i) => ( <div key={i} className="flex h-[62px] w-[62px] items-center justify-center rounded-lg border border-hairline bg-surface text-ink-soft"> <Icon /> </div> ))} </div> ))} </div> </div> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[4]} /> <div className="absolute inset-x-0 bottom-0 h-[260px] bg-[linear-gradient(var(--color-hairline)_1px,transparent_1px),linear-gradient(90deg,var(--color-hairline)_1px,transparent_1px)] bg-[size:24px_24px] opacity-60" /> <div className="absolute left-[30%] top-[260px] flex h-8 w-16 items-center justify-center gap-1 rounded-pill border border-hairline-strong bg-surface"> {[0, 1, 2].map((i) => <span key={i} className="h-1.5 w-1.5 rounded-full bg-ink-soft" />)} </div> <svg className="absolute left-[14%] top-[300px] text-ink-faint" width="28" height="36" viewBox="0 0 28 36" fill="none" stroke="currentColor"><path d="M2 2v30l8-8 12-2z" /></svg> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[5]} /> <svg viewBox="0 0 200 180" className="absolute inset-x-6 top-[170px] text-ink-faint" fill="none" stroke="currentColor" aria-hidden="true"> <path d="M100 10 170 45v80l-70 35-70-35V45z" /> <path d="M30 45l70 35 70-35M100 80v80" /> {[[60, 60], [150, 30], [140, 110], [40, 140]].map(([x, y], i) => <circle key={i} cx={x} cy={y} r="3" fill="var(--color-brand-bright)" stroke="none" />)} </svg> <ul className="absolute bottom-5 left-6 space-y-2 text-body text-ink"> <li className="flex items-center gap-2"><span className="h-3 w-3 rounded-full border border-ink-soft" />Northwind AI</li> <li className="flex items-center gap-2"><span className="h-3 w-3 rounded-full border border-ink-soft" />Kitefield Models</li> </ul> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[6]} /> <div className="absolute inset-x-0 bottom-6 space-y-3 overflow-hidden px-4"> {routes.map((r, i) => ( <div key={r} className="flex items-center gap-3 border-y border-dashed border-hairline py-1" style={{ marginLeft: i * 6 }}> <span className="rounded-md border border-hairline bg-surface px-2 py-1 font-mono text-caption text-ink-soft">{r}</span> <span className="rounded-pill border border-hairline bg-surface-muted px-2.5 py-1 font-mono text-caption text-ink-muted">/v1/<span className="text-ink">{r}</span></span> </div> ))} </div> </article> </Stagger> <p className="mt-6 font-display text-h3 text-ink"> {tagline} <span className="text-ink-muted">{taglineMuted}</span> </p> </div> </section> ); } // ---- Yoink motion (inlined, no dependencies): Stagger ---- 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; } /** 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> ); }"use client"; import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; type Card = { title: string; before: string; strong: string; after: string }; type Props = { tagline?: string; taglineMuted?: string; }; const Icon = () => ( <svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" strokeWidth="1.3" aria-hidden="true"> <rect x="3" y="3" width="12" height="12" rx="3" /> <path d="M6 9h6" /> </svg> ); const Desc = ({ c }: { c: Card }) => ( <p className="mt-4 text-emerald-body text-muted-foreground"> {c.before} <span className="text-foreground">{c.strong}</span> {c.after} </p> ); const shell = "group relative overflow-hidden rounded-xl border border-border bg-gradient-to-b from-foreground/[0.04] to-foreground/[0.02] bg-card transition-colors duration-emerald-base-transition ease-emerald-base-transition hover:border-border"; function Head({ c }: { c: Card }) { return ( <div className="p-6 pb-0"> <div className="flex items-center gap-2.5 font-sans text-emerald-lead text-foreground"> <span className="text-muted-foreground"><Icon /></span> {c.title} </div> <Desc c={c} /> </div> ); } const cards: Card[] = [ { title: "Ledger Store", before: "Every workspace gets ", strong: "a durable relational store", after: ", tuned for steady reads and careful writes." }, { title: "Access", before: "", strong: "Invite teammates and set roles", after: ", keeping each record visible only to the right people." }, { title: "Workers", before: "Run small scripts near your data ", strong: "with no servers to babysit", after: "." }, { title: "Files", before: "", strong: "Keep, sort, and share", after: " documents, clips and scans in one place." }, { title: "Live Sync", before: "", strong: "Show who is online", after: " and keep shared boards in step as people edit." }, { title: "Search", before: "Index your notes and ", strong: "find similar items by meaning", after: " in milliseconds." }, { title: "Endpoints", before: "Ready-made ", strong: "HTTP endpoints", after: " for every table you create." }, ]; const emails = ["mira.t@example.com", "jon.park@example.com", "sol22@example.com", "kai.b@example.com", "ana.r@example.com"]; const routes = ["orders", "people", "teams", "invoices", "regions", "labels"]; export default function HairlineBentoProductGrid({ tagline = "Pick a piece or take the lot.", taglineMuted = "Simple parts that fit together as one workspace.", }: Props) { return ( <section className="bg-background px-4 py-16 text-foreground sm:px-6"> <style>{`@keyframes hb-drift{from{transform:translateX(0)}to{transform:translateX(-50%)}}@media (prefers-reduced-motion:reduce){.hb-drift{animation:none!important}}`}</style> <div className="mx-auto max-w-[1088px]"> <Stagger step={70} from="up" className="grid gap-3 md:grid-cols-4"> <article className={`${shell} md:col-span-2 flex flex-col sm:flex-row min-h-[400px]`}> <div className="sm:w-1/2 flex flex-col justify-between pb-6"> <Head c={cards[0]} /> <ul className="px-6 space-y-1.5 text-emerald-body text-foreground"> {["Fully portable", "Role rules built in", "Simple to extend"].map((t) => ( <li key={t} className="flex items-center gap-2"> <svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" strokeWidth="1.4"><path d="m2 7 3.5 3.5L12 3.5" /></svg> {t} </li> ))} </ul> </div> <div className="flex flex-1 items-center justify-center p-6"> <svg width="170" height="170" viewBox="0 0 170 170" fill="none" className="text-border" aria-hidden="true"> <rect x="1" y="1" width="168" height="168" rx="14" stroke="currentColor" /> <circle cx="85" cy="85" r="52" stroke="currentColor" strokeWidth="6" /> <circle cx="85" cy="85" r="28" stroke="currentColor" strokeWidth="6" /> <circle cx="85" cy="85" r="6" fill="currentColor" /> </svg> </div> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[1]} /> <div className="absolute inset-x-0 bottom-8 overflow-hidden"> <div className="hb-drift flex w-max gap-3" style={{ animation: "hb-drift 35s linear infinite" }}> {[...emails, ...emails].map((e, i) => ( <div key={i} className={`flex h-14 w-56 items-center justify-center rounded-md border border-border bg-card font-mono text-emerald-caption text-muted-foreground ${i % 3 === 1 ? "blur-sm" : ""}`}>{e}</div> ))} </div> </div> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[2]} /> <div className="absolute left-1/2 top-[180px] -translate-x-1/2 whitespace-nowrap rounded-full border border-border bg-card px-3 py-2 font-mono text-emerald-caption"> <span className="text-muted-foreground">$ ledger </span><span className="text-primary">workers push</span> </div> <svg viewBox="0 0 260 160" className="absolute inset-x-0 bottom-0 w-full text-border" fill="none" stroke="currentColor" aria-hidden="true"> {[30, 60, 90, 120].map((r) => <ellipse key={r} cx="130" cy="170" rx={r * 2} ry={r * 1.3} />)} {[0, 1, 2, 3, 4, 5].map((i) => <path key={i} d={`M130 170 L${i * 52} 30`} />)} <circle cx="60" cy="90" r="3" fill="var(--color-foreground)" /> <circle cx="215" cy="140" r="3" fill="var(--color-foreground)" /> </svg> </article> <article className={`${shell} min-h-[400px] md:col-span-1`}> <Head c={cards[3]} /> <div className="absolute bottom-0 left-2 overflow-hidden right-0"> <div className="hb-drift flex w-max gap-3 pb-2" style={{ animation: "hb-drift 30s linear infinite reverse" }}> {[0, 1].map((k) => ( <div key={k} className="grid grid-flow-col grid-rows-3 gap-3"> {Array.from({ length: 18 }).map((_, i) => ( <div key={i} className="flex h-[62px] w-[62px] items-center justify-center rounded-lg border border-border bg-card text-muted-foreground"> <Icon /> </div> ))} </div> ))} </div> </div> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[4]} /> <div className="absolute inset-x-0 bottom-0 h-[260px] bg-[linear-gradient(var(--color-border)_1px,transparent_1px),linear-gradient(90deg,var(--color-border)_1px,transparent_1px)] bg-[size:24px_24px] opacity-60" /> <div className="absolute left-[30%] top-[260px] flex h-8 w-16 items-center justify-center gap-1 rounded-full border border-border bg-card"> {[0, 1, 2].map((i) => <span key={i} className="h-1.5 w-1.5 rounded-full bg-foreground" />)} </div> <svg className="absolute left-[14%] top-[300px] text-muted-foreground" width="28" height="36" viewBox="0 0 28 36" fill="none" stroke="currentColor"><path d="M2 2v30l8-8 12-2z" /></svg> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[5]} /> <svg viewBox="0 0 200 180" className="absolute inset-x-6 top-[170px] text-muted-foreground" fill="none" stroke="currentColor" aria-hidden="true"> <path d="M100 10 170 45v80l-70 35-70-35V45z" /> <path d="M30 45l70 35 70-35M100 80v80" /> {[[60, 60], [150, 30], [140, 110], [40, 140]].map(([x, y], i) => <circle key={i} cx={x} cy={y} r="3" fill="var(--color-primary)" stroke="none" />)} </svg> <ul className="absolute bottom-5 left-6 space-y-2 text-emerald-body text-foreground"> <li className="flex items-center gap-2"><span className="h-3 w-3 rounded-full border border-muted-foreground" />Northwind AI</li> <li className="flex items-center gap-2"><span className="h-3 w-3 rounded-full border border-muted-foreground" />Kitefield Models</li> </ul> </article> <article className={`${shell} min-h-[400px]`}> <Head c={cards[6]} /> <div className="absolute inset-x-0 bottom-6 space-y-3 overflow-hidden px-4"> {routes.map((r, i) => ( <div key={r} className="flex items-center gap-3 border-y border-dashed border-border py-1" style={{ marginLeft: i * 6 }}> <span className="rounded-md border border-border bg-card px-2 py-1 font-mono text-emerald-caption text-muted-foreground">{r}</span> <span className="rounded-full border border-border bg-muted px-2.5 py-1 font-mono text-emerald-caption text-muted-foreground">/v1/<span className="text-foreground">{r}</span></span> </div> ))} </div> </article> </Stagger> <p className="mt-6 font-sans text-emerald-h3 text-foreground"> {tagline} <span className="text-muted-foreground">{taglineMuted}</span> </p> </div> </section> ); } // ---- Yoink motion (inlined, no dependencies): Stagger ---- 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; } /** 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> ); }
Quality checks
Automated, in a real browser · 4d 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.