Motion & effects / Marquees & tickers
Faded Logo Marquee
Single row of white monochrome customer logos beneath a centered three-line headline, edges dissolving via horizontal mask.
Rebuilt from mercury.com in the Twilight Ledger style.
npx shadcn@latest add https://justyoink.it/r/twilight-ledger-0e1ecf/blocks/logo-marquee.json
Looks exactly like mercury.com: brings its fonts and colours, namespaced so your own theme stays untouched.
npx shadcn@latest add https://justyoink.it/r/twilight-ledger-0e1ecf/mine/logo-marquee.json
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
Pass `headline` (array of lines) and `logos` (name + geometric mark type) as props; both have defaults. The row scrolls continuously and fades at both edges via a CSS mask.
components/logo-marquee.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; type Logo = { name: string; mark: "circle" | "square" | "triangle" | "diamond" | "bars" | "ring" | "drop" }; type Props = { headline?: string[]; logos?: Logo[]; }; const defaultLogos: Logo[] = [ { name: "Northwind", mark: "circle" }, { name: "Altura", mark: "triangle" }, { name: "Lumen", mark: "ring" }, { name: "Kitefield", mark: "diamond" }, { name: "Brightpath", mark: "bars" }, { name: "Harbor", mark: "square" }, { name: "Quillon", mark: "drop" }, ]; function Mark({ type }: { type: Logo["mark"] }) { const c = "h-6 w-6 shrink-0"; switch (type) { case "circle": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="currentColor" /></svg>; case "square": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="4" fill="currentColor" /></svg>; case "triangle": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l10 18H2z" fill="currentColor" /></svg>; case "diamond": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l10 10-10 10L2 12z" fill="currentColor" /></svg>; case "bars": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><path d="M4 4h4v16H4zM10 8h4v12h-4zM16 12h4v8h-4z" fill="currentColor" /></svg>; case "ring": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="8" fill="none" stroke="currentColor" strokeWidth="4" /></svg>; default: return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2c4 6 7 9 7 13a7 7 0 01-14 0c0-4 3-7 7-13z" fill="currentColor" /></svg>; } } export default function FadedLogoMarquee({ headline = ["Trusted by 300K+ of", "the most curious teams", "building things around the world"], logos = defaultLogos, }: Props) { return ( <section className="bg-canvas text-ink py-24 md:py-32"> <Reveal from="up" distance={50} duration={670} delay={150} className="mx-auto max-w-3xl px-6 text-center"> <h2 className="font-display text-h2 text-ink"> {headline.map((line, i) => ( <span key={i} className="block">{line}</span> ))} </h2> </Reveal> <Reveal from="up" distance={50} duration={670} delay={150} className="mt-12"> <div className="overflow-hidden text-ink" style={{ maskImage: "linear-gradient(90deg, transparent, #fff 20%, #fff 80%, transparent)", WebkitMaskImage: "linear-gradient(90deg, transparent, #fff 20%, #fff 80%, transparent)", }} > <Marquee speed={40} pauseOnHover={false} fade={false} gap={56}> {logos.map((l) => ( <div key={l.name} className="flex items-center gap-2 whitespace-nowrap font-sans text-xl font-semibold tracking-tight"> <Mark type={l.mark} /> <span>{l.name}</span> </div> ))} </Marquee> </div> </Reveal> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Marquee ---- 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> ); } const YK_MARQUEE_CSS = `@keyframes yk-marquee-x{to{transform:translate3d(calc(-1 * var(--yk-shift)),0,0)}} @keyframes yk-marquee-y{to{transform:translate3d(0,calc(-1 * var(--yk-shift)),0)}} [data-yk-marquee][data-pause]:hover [data-yk-track]{animation-play-state:paused} @media (prefers-reduced-motion:reduce){[data-yk-track]{animation:none!important}}`; /** An endless, seamless scrolling row (or column) of items: logos, quotes, tags. */ function Marquee({ children, speed = 40, reverse = false, vertical = false, pauseOnHover = true, fade = true, gap = 48, className, style, }: { children?: ReactNode; /** pixels per second */ speed?: number; reverse?: boolean; vertical?: boolean; pauseOnHover?: boolean; fade?: boolean; gap?: number; className?: string; style?: CSSProperties; }) { const box = useRef<HTMLDivElement>(null); const group = useRef<HTMLDivElement>(null); const [m, setM] = useState({ copies: 2, size: 0 }); useEffect(() => { const measure = () => { const b = box.current, g = group.current; if (!b || !g) return; const size = vertical ? g.offsetHeight : g.offsetWidth; const room = vertical ? b.offsetHeight : b.offsetWidth; if (size > 0) setM({ size, copies: Math.max(2, Math.ceil(room / size) + 1) }); }; measure(); const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null; if (box.current) ro?.observe(box.current); if (group.current) ro?.observe(group.current); return () => ro?.disconnect(); }, [vertical]); // the copies are only there to fill the loop: hide them from screen readers and keyboards useEffect(() => { box.current?.querySelectorAll("[data-yk-copy]").forEach((el) => el.setAttribute("inert", "")); }, [m.copies]); const edge = vertical ? "to bottom" : "to right"; const mask = fade ? `linear-gradient(${edge}, transparent, black 10%, black 90%, transparent)` : undefined; const dir = vertical ? "column" : "row"; const items = (copy: number) => ( <div key={copy} ref={copy === 0 ? group : undefined} data-yk-copy={copy > 0 ? "" : undefined} aria-hidden={copy > 0 || undefined} style={{ display: "flex", flexDirection: dir, flexShrink: 0, alignItems: "center", gap, [vertical ? "paddingBottom" : "paddingRight"]: gap }} > {children} </div> ); return ( <div ref={box} data-yk-marquee="" data-pause={pauseOnHover ? "" : undefined} className={className} style={{ overflow: "hidden", maskImage: mask, WebkitMaskImage: mask, ...style }} > <style>{YK_MARQUEE_CSS}</style> <div data-yk-track="" style={{ display: "flex", flexDirection: dir, width: vertical ? "100%" : "max-content", ["--yk-shift" as string]: `${m.size}px`, animation: m.size ? `yk-marquee-${vertical ? "y" : "x"} ${m.size / Math.max(speed, 1)}s linear infinite${reverse ? " reverse" : ""}` : undefined, }} > {Array.from({ length: m.copies }, (_, i) => items(i))} </div> </div> ); }"use client"; import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; type Logo = { name: string; mark: "circle" | "square" | "triangle" | "diamond" | "bars" | "ring" | "drop" }; type Props = { headline?: string[]; logos?: Logo[]; }; const defaultLogos: Logo[] = [ { name: "Northwind", mark: "circle" }, { name: "Altura", mark: "triangle" }, { name: "Lumen", mark: "ring" }, { name: "Kitefield", mark: "diamond" }, { name: "Brightpath", mark: "bars" }, { name: "Harbor", mark: "square" }, { name: "Quillon", mark: "drop" }, ]; function Mark({ type }: { type: Logo["mark"] }) { const c = "h-6 w-6 shrink-0"; switch (type) { case "circle": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="currentColor" /></svg>; case "square": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="4" fill="currentColor" /></svg>; case "triangle": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l10 18H2z" fill="currentColor" /></svg>; case "diamond": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l10 10-10 10L2 12z" fill="currentColor" /></svg>; case "bars": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><path d="M4 4h4v16H4zM10 8h4v12h-4zM16 12h4v8h-4z" fill="currentColor" /></svg>; case "ring": return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="8" fill="none" stroke="currentColor" strokeWidth="4" /></svg>; default: return <svg className={c} viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2c4 6 7 9 7 13a7 7 0 01-14 0c0-4 3-7 7-13z" fill="currentColor" /></svg>; } } export default function FadedLogoMarquee({ headline = ["Trusted by 300K+ of", "the most curious teams", "building things around the world"], logos = defaultLogos, }: Props) { return ( <section className="bg-background text-foreground py-24 md:py-32"> <Reveal from="up" distance={50} duration={670} delay={150} className="mx-auto max-w-3xl px-6 text-center"> <h2 className="font-sans text-twilight-h2 text-foreground"> {headline.map((line, i) => ( <span key={i} className="block">{line}</span> ))} </h2> </Reveal> <Reveal from="up" distance={50} duration={670} delay={150} className="mt-12"> <div className="overflow-hidden text-foreground" style={{ maskImage: "linear-gradient(90deg, transparent, #fff 20%, #fff 80%, transparent)", WebkitMaskImage: "linear-gradient(90deg, transparent, #fff 20%, #fff 80%, transparent)", }} > <Marquee speed={40} pauseOnHover={false} fade={false} gap={56}> {logos.map((l) => ( <div key={l.name} className="flex items-center gap-2 whitespace-nowrap font-sans text-xl font-semibold tracking-tight"> <Mark type={l.mark} /> <span>{l.name}</span> </div> ))} </Marquee> </div> </Reveal> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Marquee ---- 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> ); } const YK_MARQUEE_CSS = `@keyframes yk-marquee-x{to{transform:translate3d(calc(-1 * var(--yk-shift)),0,0)}} @keyframes yk-marquee-y{to{transform:translate3d(0,calc(-1 * var(--yk-shift)),0)}} [data-yk-marquee][data-pause]:hover [data-yk-track]{animation-play-state:paused} @media (prefers-reduced-motion:reduce){[data-yk-track]{animation:none!important}}`; /** An endless, seamless scrolling row (or column) of items: logos, quotes, tags. */ function Marquee({ children, speed = 40, reverse = false, vertical = false, pauseOnHover = true, fade = true, gap = 48, className, style, }: { children?: ReactNode; /** pixels per second */ speed?: number; reverse?: boolean; vertical?: boolean; pauseOnHover?: boolean; fade?: boolean; gap?: number; className?: string; style?: CSSProperties; }) { const box = useRef<HTMLDivElement>(null); const group = useRef<HTMLDivElement>(null); const [m, setM] = useState({ copies: 2, size: 0 }); useEffect(() => { const measure = () => { const b = box.current, g = group.current; if (!b || !g) return; const size = vertical ? g.offsetHeight : g.offsetWidth; const room = vertical ? b.offsetHeight : b.offsetWidth; if (size > 0) setM({ size, copies: Math.max(2, Math.ceil(room / size) + 1) }); }; measure(); const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null; if (box.current) ro?.observe(box.current); if (group.current) ro?.observe(group.current); return () => ro?.disconnect(); }, [vertical]); // the copies are only there to fill the loop: hide them from screen readers and keyboards useEffect(() => { box.current?.querySelectorAll("[data-yk-copy]").forEach((el) => el.setAttribute("inert", "")); }, [m.copies]); const edge = vertical ? "to bottom" : "to right"; const mask = fade ? `linear-gradient(${edge}, transparent, black 10%, black 90%, transparent)` : undefined; const dir = vertical ? "column" : "row"; const items = (copy: number) => ( <div key={copy} ref={copy === 0 ? group : undefined} data-yk-copy={copy > 0 ? "" : undefined} aria-hidden={copy > 0 || undefined} style={{ display: "flex", flexDirection: dir, flexShrink: 0, alignItems: "center", gap, [vertical ? "paddingBottom" : "paddingRight"]: gap }} > {children} </div> ); return ( <div ref={box} data-yk-marquee="" data-pause={pauseOnHover ? "" : undefined} className={className} style={{ overflow: "hidden", maskImage: mask, WebkitMaskImage: mask, ...style }} > <style>{YK_MARQUEE_CSS}</style> <div data-yk-track="" style={{ display: "flex", flexDirection: dir, width: vertical ? "100%" : "max-content", ["--yk-shift" as string]: `${m.size}px`, animation: m.size ? `yk-marquee-${vertical ? "y" : "x"} ${m.size / Math.max(speed, 1)}s linear infinite${reverse ? " reverse" : ""}` : undefined, }} > {Array.from({ length: m.copies }, (_, i) => items(i))} </div> </div> ); }
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.