GooseUI

Components

Video Hover Preview

New

A video card with a poster, made for video testimonials. On hover or keyboard focus the clip plays muted and the captions run over the picture, so the viewer gets the point without sound. A click turns the sound on, a second click pauses. Only one video plays on the page at a time: a shared module-level registry pauses the previous one. It is a client component with no dependencies. Captions are plain .vtt files, the cues are drawn by the component itself, so they are never clipped by the rounded card and look the same in every browser.

Browser Support

WebVTT

Reads the cues of a .vtt file through TextTrack and its cuechange event.

Your browser:

Preview

Hover a card: the clip plays muted with captions. Click it to turn the sound on, click again to pause. The CC button switches the caption language. Start another card and the first one stops.

Louise Brosnan

Chef, Dingle, Ireland

Education for that is key.

Toni Aarniviita

Head chef, Finland

Try to minimize that as much as possible.

Arto Huhtala

Head chef, Finland

Every day is different, so you need to cope with the pressure.

Installation

npx shadcn@latest add @gooseui/video-hover-preview
pnpm dlx shadcn@latest add @gooseui/video-hover-preview
yarn dlx shadcn@latest add @gooseui/video-hover-preview
bunx --bun shadcn@latest add @gooseui/video-hover-preview

Usage

import { VideoHoverPreview } from "@/components/ui/video-hover-preview"

const reviews = [
  {
    slug: "elena-marsh",
    name: "Elena Marsh",
    role: "Head of product design",
    quote: "Three months later I lead the whole design team.",
  },
  // ...
]

export default function Example() {
  return (
    <div className="grid gap-4 sm:grid-cols-3">
      {reviews.map((review) => (
        <VideoHoverPreview
          key={review.slug}
          src={`/videos/${review.slug}.mp4`}
          poster={`/videos/${review.slug}.webp`}
          aspect="9/16"
          controls="custom"
          captions={[
            { src: `/videos/${review.slug}.en.vtt`, srclang: "en", label: "English", default: true },
            { src: `/videos/${review.slug}.ru.vtt`, srclang: "ru", label: "Русский" },
          ]}
          name={review.name}
          role={review.role}
          quote={review.quote}
          className="rounded-2xl"
        />
      ))}
    </div>
  )
}

Examples

Landscape previews without captions

The default 16/9 card with a custom overlay in children. Without captions there is no CC button, and the native controls appear after the click.

Mountain ridge0:10
City at night0:10
Working from above0:10
<VideoHoverPreview
  src="/videos/mountains.mp4"
  poster="/videos/mountains.webp"
  labels={{ play: "Play video: Mountain ridge" }}
>
  <div className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-3 pt-10 text-sm text-white">
    Mountain ridge
  </div>
</VideoHoverPreview>

Several caption languages

Pass one entry per language. The CC button cycles through the languages and then switches captions off; the track with default starts selected. controls="custom" replaces the native bar with play, sound, captions and a seek line.

Toni Aarniviita

Head chef, Finland

<VideoHoverPreview
  src="/videos/sofia-reyes.mp4"
  poster="/videos/sofia-reyes.webp"
  aspect="9/16"
  controls="custom"
  captions={[
    { src: "/videos/sofia-reyes.en.vtt", srclang: "en", label: "English", default: true },
    { src: "/videos/sofia-reyes.ru.vtt", srclang: "ru", label: "Русский" },
  ]}
  name="Sofia Reyes"
  role="Marketing manager"
  labels={{ captions: "Captions", captionsOff: "off" }}
/>

Captions files

A regular WebVTT file. Cue text may contain line breaks; tags such as <b> are stripped.

WEBVTT

1
00:00.400 --> 00:03.200
The lessons are short, so I could
study between meetings.

2
00:03.400 --> 00:07.000
I took the checklists straight
into my campaigns.

Click only

hoverPreview={false} turns off the muted preview: the poster stays until the click.

City at night0:10
<VideoHoverPreview
  src="/videos/layers.mp4"
  poster="/videos/layers.jpg"
  hoverPreview={false}
/>

Props

PropTypeDefaultDescription
srcstring-Video URL
posterstring-Poster shown before playback
childrenReactNode-Overlay over the poster: caption, duration, badge
captions{ src: string; srclang: string; label: string; default?: boolean }[]-WebVTT tracks: src, srclang, label and optional default. Cues are drawn over the video, muted or not
aspect"16/9" | "9/16" | "4/5" | "1/1""16/9"Card ratio. Any other ratio goes through className
nameReactNode-Person name at the top of the card
roleReactNode-Role or company under the name
quoteReactNode-Short quote at the bottom of the card until playback starts
controls"native" | "custom""native"Controls after the click: the browser bar or ours (play, sound, captions, seek)
hasAudiobooleandetectedWhether the video has sound. Detected by default and the sound button stays hidden until known or when there is none; set it to skip the detection
hoverPreviewbooleantruePlay muted on mouse hover and keyboard focus
labels{ play?: string; pause?: string; mute?: string; unmute?: string; captions?: string; captionsOff?: string; seek?: string }English textsAccessible names: play, pause, mute, unmute, captions, captionsOff, seek
videoClassNamestring-Classes for the video element
onModeChange(mode: "idle" | "preview" | "playing") => void-Called when the card switches between idle, preview and playing
classNamestring-Card classes

Features

  • One at a time: starting any card pauses the one that was playing, including through native controls
  • Touch screens: hover is ignored for touch, a tap starts playback with sound
  • Keyboard: focus with Tab starts the muted preview, Enter plays with sound, then Space pauses, arrows seek, M mutes, C switches captions
  • Pauses off screen: an IntersectionObserver stops the video when the card scrolls away
  • Reduced motion: no muted preview on hover or focus, the video starts only on click