Cards & content / Carousels

Center-Focus Video Story Carousel

Centered headline and subhead above a Swiper carousel of large rounded video cards; the active card is full-scale while neighbours peek in smaller at the edges. A small floating pill control bar below includes a mute button, play + name label and a circular avatar. Fullscreen icon sits in the top right of the card.

Rebuilt from seed.com in the Verdant Lab Editorial style.

npx shadcn@latest add https://justyoink.it/r/verdant-lab-editorial/blocks/video-testimonial-carousel.json

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

Images4 in this component. Swap any for a library image or one of your own.All images in this style →

Choose an image

Image

Loading…

Usage

Props: heading, subheading, and stories (array of {name, caption, image}). Drag/swipe or click a neighbouring card to change the active slide; the pill bar toggles mute and play state.

components/video-testimonial-carousel.tsx
"use client";

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

type Story = { name: string; caption: string; image: string };

const defaultStories: Story[] = [
  { name: "Maya", caption: "Member Stories", image: "https://yoink-app.fly.dev/stock/people-1.jpg" },
  { name: "Jonas", caption: "Member Stories", image: "https://yoink-app.fly.dev/stock/people-2.jpg" },
  { name: "Priya", caption: "Member Stories", image: "https://yoink-app.fly.dev/stock/people-3.jpg" },
  { name: "Theo", caption: "Member Stories", image: "https://yoink-app.fly.dev/stock/people-6.jpg" },
];

export default function CenterFocusVideoStoryCarousel({
  heading = "Thousands of journeys, one shared habit.",
  subheading = "Hear how everyday people are building better routines with Northwind.",
  stories = defaultStories,
}: {
  heading?: string;
  subheading?: string;
  stories?: Story[];
}) {
  const [active, setActive] = useState(0);
  const [playing, setPlaying] = useState(false);
  const [muted, setMuted] = useState(true);
  const startX = useRef<number | null>(null);

  const go = (i: number) => setActive(Math.max(0, Math.min(stories.length - 1, i)));
  const current = stories[active];

  return (
    <section className="bg-canvas text-ink font-sans py-20 overflow-hidden">
      <Reveal from="up" className="mx-auto max-w-2xl px-6 text-center">
        <h2 className="text-h2 text-ink">{heading}</h2>
        <p className="mt-4 text-body text-ink">{subheading}</p>
      </Reveal>

      <div
        className="relative mt-10 select-none touch-pan-y"
        onPointerDown={(e) => (startX.current = e.clientX)}
        onPointerUp={(e) => {
          if (startX.current === null) return;
          const dx = e.clientX - startX.current;
          if (dx < -50) go(active + 1);
          else if (dx > 50) go(active - 1);
          startX.current = null;
        }}
      >
        <div
          className="flex gap-6 transition-transform duration-500 ease-in-out motion-reduce:transition-none"
          style={{ transform: `translateX(calc(50vw - min(45vw, 456px) - ${active} * (min(90vw, 912px) + 24px)))`, width: "max-content" }}
        >
          {stories.map((s, i) => {
            const isActive = i === active;
            const offset = i < active ? 40 : i > active ? -40 : 0;
            return (
              <div
                key={s.name}
                onClick={() => go(i)}
                className={`relative shrink-0 overflow-hidden rounded-panel transition-all duration-300 ease-in-out ${isActive ? "opacity-100" : "opacity-90 cursor-pointer"}`}
                style={{
                  width: "min(90vw, 912px)",
                  aspectRatio: "16/9",
                  transform: isActive ? "scale(1)" : `translateX(${offset}px) scale(0.95)`,
                }}
              >
                <img src={s.image} alt={`${s.name}, member story`} width={1600} height={900} loading="lazy" draggable={false} className="h-full w-full object-cover" />
                <div className="absolute inset-0 bg-scrim/20" />
                <div className="absolute inset-x-0 top-1/2 flex -translate-y-1/2 items-center justify-between px-[7%] text-canvas">
                  <span className="text-h3">Northwind</span>
                  <span className="text-lead hidden sm:block">{s.caption}</span>
                </div>
                <button
                  type="button"
                  aria-label="Enter fullscreen"
                  className="absolute right-4 top-4 grid h-7 w-10 place-items-center rounded-pill bg-frost-glass text-canvas backdrop-blur focus-visible:outline focus-visible:outline-2 focus-visible:outline-canvas"
                >
                  <svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.3"><path d="M1 4V1h3M8 1h3v3M11 8v3H8M4 11H1V8" /></svg>
                </button>
              </div>
            );
          })}
        </div>
      </div>

      <div className="mx-auto mt-2 flex w-fit items-center gap-2 rounded-pill bg-surface-foam p-2 shadow-capsule-drop">
        <button
          type="button"
          aria-label={muted ? "Unmute" : "Mute"}
          aria-pressed={!muted}
          onClick={() => setMuted(!muted)}
          className="grid h-9 w-9 place-items-center rounded-pill bg-ink text-canvas transition-all duration-ui-hover ease-ui-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-ink focus-visible:outline-offset-2"
        >
          <svg width="14" height="14" viewBox="0 0 14 14" fill="currentColor"><path d="M2 5h2l3-2v8L4 9H2z" />{!muted && <path d="M9 4.5a3.5 3.5 0 010 5" stroke="currentColor" fill="none" />}{muted && <path d="M9 5l3 4M12 5l-3 4" stroke="currentColor" />}</svg>
        </button>
        <button
          type="button"
          onClick={() => setPlaying(!playing)}
          aria-pressed={playing}
          className="flex h-9 items-center gap-2 rounded-pill bg-canvas px-4 text-label transition-all duration-ui-hover ease-ui-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-ink"
        >
          <svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor" aria-hidden="true">{playing ? <path d="M2 1h2v8H2zM6 1h2v8H6z" /> : <path d="M2 1l7 4-7 4z" />}</svg>
          {current.name}
        </button>
        <span aria-hidden="true" className="grid h-9 w-9 place-items-center rounded-pill bg-gradient-to-br from-lemongrass to-forest-soft text-caption text-canvas border-2 border-canvas">
          {current.name[0]}
        </span>
      </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
—

More from Verdant Lab Editorial

The whole style →

Hairline Plus Accordion

Accordions

Frosted Glass Photo Hero

Heroes

Offer Popup Dialog

Dialogs & modals

Timeline Benefit Tiles

Feature sections

Glass Panel Annotated Capsule

Feature sections

Centered Product Quartet

Feature sections