Skip to content

Lite YouTube

YouTube thumbnail and play button; the player only loads on the click.

$npx shadcn@latest add https://framebrick.co/r/lite-youtube.json

From the Findit template, see it in context.

Nothing is loaded from YouTube until you press play — the still is served from here.

Examples

Round button and overlay

A veil that lightens on hover, a round play button whose icon grows, and the video in a dialog over the page.

<LiteYouTube url="https://www.youtube.com/watch?v=YE7VzlLtp-4" title="Big Buck Bunny" poster="/bunny.jpg" play="circle" overlay />

Installation

$ npx shadcn@latest add https://framebrick.co/r/lite-youtube.json

Usage

import { LiteYouTube } from "@/components/ui/lite-youtube";

<LiteYouTube url="https://www.youtube.com/watch?v=YE7VzlLtp-4" title="Big Buck Bunny" />

Props

PropTypeDefaultDescription
urlstring—A YouTube URL (watch, youtu.be, embed, shorts) or the bare video id.
titlestring—The video's title: read to screen readers and used as the player's title.
playLabelstring"Play"Word before the title in the button's label.
thumbnail"sd" | "hq" | "max""sd"Thumbnail quality; max is sharper but missing on some videos.
posterstring—Your own still instead of YouTube's thumbnail, so nothing is requested from YouTube before the click.
overlaybooleanfalsePlay in a dialog over the page — 80% of the screen's width at 16:9, over a black 80% backdrop — instead of in place (Compose Digi).
play"youtube" | "circle""youtube"YouTube's own red button, or "circle": a veil on the picture (50%, 30% on hover) and a round button whose play icon grows to 1.5× when pointed at (Compose Digi).
closeLabelstring"Close video"The name of the close button, which shows when the keyboard reaches it in the dialog.
classNamestring—Classes for the frame: its width.
  • A YouTube iframe pulls about a megabyte before anyone watches; this pulls one image.
  • The player comes from youtube-nocookie.com, so YouTube sets no cookie until someone presses play. The default still does come from YouTube's image host — pass `poster` to serve your own and keep the page free of YouTube until the click (this demo does).
  • The play button is YouTube's own: dark grey at 80%, red on hover and on keyboard focus.
  • overlay uses a native <dialog>: it opens and closes at once (Framer has no transition), the page behind is inert and does not scroll, Escape or a click on the backdrop closes it, and the focus goes back to the play button. The player only exists while it is open, so closing stops the video. Framer has no close button, so there is a visible way out for the keyboard: a button that shows when the keyboard reaches it. The player is the smaller of 80% of the screen's width and 90% of its height at 16:9, so it never runs off a short window.
  • play="circle" is the About video card of Compose Digi: the veil and the icon use Framer's spring 400 / 30 / 1 (about 0.45 s, a 1% overshoot) as a CSS curve, and the circle is 14% of the card's width between 72 and 150 px, so it follows the card and not the window. The light ring and icon sit on the veil, so check them on your own picture the way you would a caption (a very pale still needs a stronger veil than 50%).

AI prompt

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

Create a React + Tailwind CSS component called LiteYouTube (no animation library) — a facade for a YouTube embed.
- Read the video id from a YouTube URL (watch, youtu.be, embed, shorts) or accept the bare id.
- Before the click: a 16:9 rounded-lg frame with the thumbnail from https://i.ytimg.com/vi_webp/<id>/sddefault.webp
  (plain <img>, object-cover) inside a button that fills the frame, labelled "<playLabel>: <title>".
  A "poster" prop replaces that URL with the caller's own image, so nothing is requested from YouTube before the click.
- On top, YouTube's own play button: an svg with viewBox "0 0 68 48", the rounded-rectangle path filled #212121 at
  80% opacity turning #f00 at 100% on hover and on keyboard focus (transition 100ms cubic-bezier(0.4,0,1,1)),
  with the white triangle "M 45,24 27,14 27,34".
- After the click, replace it with an iframe from https://www.youtube-nocookie.com/embed/<id> with
  autoplay=1&rel=0&modestbranding=1&iv_load_policy=3&playsinline=1, allowFullScreen, a title, and the usual allow list.
- Visible focus ring (ring-[3px] ring-ring/50 inset).
- Options. play="circle" replaces YouTube's button with a bg-black/50 veil (bg-black/30 on hover and focus) and a round button
  in the middle (size clamp(4.5rem, 14cqw, 9.375rem), the frame being a container-type inline-size box; border border-white,
  text-white) holding a filled play triangle at 30% of its size that scales to 1.5 when the circle is pointed at or the button has
  keyboard focus; both transitions use Framer's spring 400 / 30 / 1 as a CSS linear() curve (about 453 ms).
  overlay renders a native <dialog> (fixed inset-0, no margin, padding or border, bg-transparent, backdrop:bg-black/80, open:flex,
  centred) in the frame: the play button calls showModal() and sets playing; the iframe (aspect-video, w-[min(80vw,calc(90vh*16/9))])
  is only rendered while playing; onClose sets playing false; a click whose target is the dialog itself closes it; Escape closes it
  natively. Lock the page's scroll (documentElement.style.overflow = "hidden") while it is open. Put a close button inside that is
  sr-only until it has keyboard focus (focus-visible:not-sr-only, absolute top-5 right-5), named by closeLabel.

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