Skip to content

Hero Video

Poster with a round play button over it; the whole frame plays and pauses.

$npx shadcn@latest add https://framebrick.co/r/hero-video.json

From the Findit template, see it in context.

The file is only fetched when you press play; the poster is all that loads before.

Examples

In view

No button: the clip plays while it is on screen and stops when it leaves; with reduced motion it stays on its poster.

<HeroVideo autoplay="view" src="/clinic.mp4" poster="/clinic.jpg" label="A look around the clinic" />

Pill

A pill with the label in it instead of the round button; it fades while the video plays.

<HeroVideo src="/review.mp4" poster="/review.jpg" label="Watch a review" caption="Watch a review" play="pill" />

Caption, veil and stop button

A caption beside the button on hover, a veil on the poster, and a stop square while it plays.

<HeroVideo
  src="/activity.mp4"
  poster="/activity.jpg"
  label="Watch our activity"
  caption="Watch our activity"
  veil
  stopButton
/>

Installation

$ npx shadcn@latest add https://framebrick.co/r/hero-video.json

Usage

import { HeroVideo } from "@/components/ui/hero-video";

<HeroVideo src="/tour.mp4" poster="/tour.jpg" label="Play the tour of 14 Almond Street" />

// Semono's video card: a caption beside the button, a veil on the poster, a stop square while it plays
<HeroVideo src="/activity.mp4" poster="/activity.jpg" label="Watch our activity" caption="Watch our activity" veil stopButton />

Props

PropTypeDefaultDescription
srcstring—The video file.
posterstring—Shown before play and while paused.
labelstring—What the button does, e.g. "Play the tour of 14 Almond Street".
autoplay"view"—view: no button; a muted loop that plays while it is on screen (a tenth showing) and pauses when it leaves, standing on its poster with reduced motion (KorDent). The frame is an image named by label and the video is aria-hidden; preload is metadata. Left out: the poster and a play button.
play"circle" | "pill""circle"The round button, or a pill with the caption (falling back to the label) in it, with its own light background, that fades while the video plays and comes back on pause (Balancee). With the pill, caption is its text and stopButton does nothing; label must say what the pill says.
captionstring—A short line beside the button while the pointer or keyboard focus is over the card and the video is not playing. The button slides left to keep the pair centred, and grows to 1.2 under the pointer.
veilbooleanfalseA 25% black layer on the poster that fades away when the video plays and comes back when it pauses.
stopButtonbooleanfalseWhile the video plays, bring the button back as a stop square, but only while the pointer or focus is over the card.
loopbooleantrueStart again when it ends.
mutedbooleantrueVideos start muted so a browser lets them play; turn it off for sound.
  • autoplay="view" is KorDent's call-to-action video at the end of nearly every page (a 1140 : 601 clinic clip, muted, looping, played only while it is on screen, still for reduced motion, with no button). An IntersectionObserver plays it when a tenth of it shows and pauses it when it leaves; reduced motion is read from matchMedia in an effect, so the markup never depends on it. It is decoration: the frame is an image named by label and the video inside is aria-hidden, always muted. preload is metadata rather than none, since it starts by itself and its first frame should be ready; the poster shows until it plays. The click-to-play video is unchanged. Blocks' about-video and media-band write their own and need not move.
  • Nothing of the video is downloaded until someone presses play (preload="none") — only the poster.
  • The button follows the video, not the click, so it comes back when the video ends or is paused from anywhere else.
  • The whole frame is a button with aria-pressed, so a keyboard reaches it and the state is announced.
  • The caption, veil and stop button are Semono's, where every part moves on a spring with a little bounce (0.2, 0.4 s). The look stays the library's: a 48 px translucent button, not Semono's white one. Without the options nothing changes.
  • Touch has no hover: a tap plays and a tap pauses, and the stop square never shows. The caption is visual only; make `label` say the same thing so the accessible name matches what is seen.
  • The slide and the growth are transforms, which <MotionConfig reducedMotion="user"> skips; the fades stay.
  • It renders a plain <video> with no <track>, so axe lists "video-caption" as a manual check. That is right for a muted clip that only decorates the page; a video with speech needs captions, which this component has no slot for — use a player that has one.

AI prompt

Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.

Create a React + Tailwind CSS + Motion (motion/react) component called HeroVideo.
- The whole frame is a button (aspect-video, rounded-lg, overflow-hidden, bg-muted, visible focus ring) holding a
  <video> with a poster, muted, loop, playsInline and preload="none", filling it with object-cover.
- A click plays or pauses. Keep a "playing" state from the video's own play, pause and ended events, not from the click.
- While paused, a 48px circle sits in the middle: bg-black/25 with backdrop-blur-md and a white play triangle.
  It rests at opacity 0.75 and goes to 1 on hover and on keyboard focus, with a spring (bounce 0, duration 0.4s).
- Accessibility: aria-label describing what plays, aria-pressed for the state.
- Options, all off by default: caption (string), veil (boolean), stopButton (boolean). Keep hovered (pointer enter and leave,
  mouse and pen only — never touch) and focused (focus-visible) in state; "over" is either. Put the button and the caption in
  an absolutely positioned flex row, items-center justify-center gap-5, so the pair stays centred: the caption mounts at once
  when over, the card is not playing and a caption is set, and the button (motion layout) slides left by half the caption's
  width plus 10px on a spring with bounce 0.2, duration 0.4s; the button scales to 1.2 under the pointer. Veil: an inset-0
  bg-black/25 layer whose opacity animates to 0 while playing, with the same spring. Stop button: while playing, the button is
  shown only when over, with a stop square instead of the triangle (a 10px rounded square).
- play="pill" (default "circle"): instead of the circle, a motion.span pill in the middle (rounded-sm, bg-background text-foreground, px-4 py-2 text-sm font-medium, shadow-xs) holding the caption, or the label, whose opacity animates to 0 while playing and back to 1 on pause (spring bounce 0, duration 0.4s). No growth, no slide, no stop square; the label prop must say what the pill says.

Be the first to know

Get new templates and components first

One short email when we release a template or a free component. No spam — unsubscribe anytime.

We use your email only for Framebrick updates. Privacy policy