Lite YouTube
YouTube thumbnail and play button; the player only loads on the click.
$npx shadcn@latest add https://framebrick.co/r/lite-youtube.jsonFrom the Findit template, see it in context.
Nothing is loaded from YouTube until you press play — the still is served from here.
import { LiteYouTube } from "@/components/ui/lite-youtube";
/*
* Big Buck Bunny (Blender Foundation, CC BY 3.0), embedded from YouTube — nothing is copied here.
* The still is our own (Unsplash, free license) through the `poster` prop, so this page asks YouTube for nothing
* until you press play. Without it the component uses YouTube's own thumbnail.
*/
export default function LiteYouTubeDemo() {
return (
<div className="flex w-full max-w-lg flex-col gap-3">
<LiteYouTube
url="https://www.youtube.com/watch?v=YE7VzlLtp-4"
title="Big Buck Bunny"
poster="/demo/lite-youtube-poster.webp"
/>
<p className="text-center text-xs text-muted-foreground">
Nothing is loaded from YouTube until you press play — the still is served from here.
</p>
</div>
);
}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.
import { LiteYouTube } from "@/components/ui/lite-youtube";
/*
* Big Buck Bunny (Blender Foundation, CC BY 3.0), embedded from YouTube — nothing is copied here. The still is ours, so this
* page asks YouTube for nothing until you press play. The video opens in a dialog over the page: Escape or a click on the
* backdrop closes it, and the focus goes back to the button.
*/
export default function LiteYouTubeOverlayDemo() {
return (
<LiteYouTube
url="https://www.youtube.com/watch?v=YE7VzlLtp-4"
title="Big Buck Bunny"
poster="/demo/lite-youtube-poster.webp"
play="circle"
overlay
className="w-full max-w-lg"
/>
);
}<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.json1. Install the dependencies.
npm install motion clsx tailwind-merge2. Add
cn()tolib/utils.ts(skip if shadcn already created it).import { clsx, type ClassValue } from "clsx"; import { extendTailwindMerge } from "tailwind-merge"; /* tailwind-merge must know the site's type scale (globals.css) is a font size, not a text color — otherwise cn("text-h6 text-muted-foreground") drops text-h6. */ const twMerge = extendTailwindMerge({ extend: { classGroups: { "font-size": [{ text: ["display", "h1", "h2", "h3", "h4", "h5", "h6"] }] } }, }); export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }3. Copy the component into
components/ui/lite-youtube.tsx."use client"; import * as React from "react"; import { cn } from "@/lib/utils"; /* * Lite YouTube — the video's thumbnail with a play button; YouTube's player is only loaded once someone clicks * (from the Findit "YouTube" embed). A YouTube iframe costs about a megabyte before anyone watches; this costs an * image. The player is embedded from youtube-nocookie.com, so YouTube sets no cookie until the click. * The play button is YouTube's own: dark grey at 80%, red on hover, as in the template. * By default the still comes from YouTube's own image host (i.ytimg.com); pass `poster` to serve your own instead, * and then nothing at all is requested from YouTube until someone presses play. * * Two options from the Compose Digi About video card (2026-10-20): * - `play="circle"`: a black veil on the picture (50%, 30% when the card is hovered or focused) and a round button with a * light ring and a filled play icon, which grows to 1.5 times its size when the button is pointed at. Framer's spring * for both: stiffness 400, damping 30, mass 1 (about 0.45 s, a 1% overshoot), written as a CSS linear() curve. * The circle is 14% of the card's width, between 72 and 150 px (a container query unit, so it follows the card, not the * window). * - `overlay`: the video plays in a dialog over the page, not in place: a black 80% backdrop and the player, 80% of the * screen's width at 16:9 (never taller than 90% of its height), opening and closing at once. The page does not scroll * behind it; a click on the backdrop or Escape closes it and the focus goes back to the play button. Framer has no close * button; here one appears when the keyboard reaches it (`closeLabel`). The player only exists while the dialog is open, so * closing stops the video. It is a native <dialog>, so the focus stays inside it and the page behind is inert. */ /** The video id of a YouTube link (watch, youtu.be or embed) — or the id itself. */ function videoId(url: string) { return url.match(/(?:v=|youtu\.be\/|embed\/|shorts\/)([\w-]{11})/)?.[1] ?? (/^[\w-]{11}$/.test(url) ? url : undefined); } export type LiteYouTubeProps = { /** A YouTube URL or the bare video id. */ url: string; /** The video's title: shown to screen readers and used as the player's title. */ title: string; playLabel?: string; /** Thumbnail quality; "max" is sharper but missing on some videos. */ thumbnail?: "sd" | "hq" | "max"; /** Your own image instead of YouTube's thumbnail, so nothing is requested from YouTube before the click. */ poster?: string; /** Play in a dialog over the page instead of in place. */ overlay?: boolean; /** "youtube": YouTube's own red button. "circle": a veil and a round button whose play icon grows on hover. */ play?: "youtube" | "circle"; /** The name of the close button that shows when the keyboard reaches it in the dialog. */ closeLabel?: string; className?: string; }; const files = { sd: "sddefault", hq: "hqdefault", max: "maxresdefault" } as const; /* Framer's spring 400 / 30 / 1 as a CSS curve (tools/ui/spring-curve.mjs: 453 ms, 0.96% off), with a cubic-bezier for a browser without linear(). */ const pop = "duration-453 ease-[cubic-bezier(0.22,1,0.36,1)] supports-[transition-timing-function:linear(0,1)]:ease-[linear(0,0.042,0.142,0.271,0.408,0.54,0.657,0.758,0.839,0.903,0.95,0.983,1.006,1.019,1.026,1.028,1.028,1.025,1.021,1.018,1.014,1.01,1.007,1.005,1.003,1.002,1.001,1,1,1)]"; const player = (id: string, title: string, className: string) => ( <iframe title={title} src={`https://www.youtube-nocookie.com/embed/${id}?autoplay=1&rel=0&modestbranding=1&iv_load_policy=3&playsinline=1`} allow="presentation; fullscreen; accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowFullScreen className={className} /> ); export function LiteYouTube({ url, title, playLabel = "Play", thumbnail = "sd", poster, overlay = false, play = "youtube", closeLabel = "Close video", className, }: LiteYouTubeProps) { const id = videoId(url); const [playing, setPlaying] = React.useState(false); const dialog = React.useRef<HTMLDialogElement>(null); /* The page does not scroll behind the dialog (Framer locks it too). */ React.useEffect(() => { if (!overlay || !playing) return; const root = document.documentElement; const previous = root.style.overflow; root.style.overflow = "hidden"; return () => { root.style.overflow = previous; }; }, [overlay, playing]); if (!id) return null; function start() { if (overlay) dialog.current?.showModal(); setPlaying(true); } return ( <div className={cn("relative aspect-video overflow-hidden rounded-lg bg-muted [container-type:inline-size]", className)}> {playing && !overlay ? ( player(id, title, "absolute inset-0 size-full border-0") ) : ( <button type="button" onClick={start} aria-label={`${playLabel}: ${title}`} aria-haspopup={overlay ? "dialog" : undefined} className="group absolute inset-0 cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset" > {/* eslint-disable-next-line @next/next/no-img-element -- the thumbnail is YouTube's own, loaded from its CDN */} <img src={poster ?? `https://i.ytimg.com/vi_webp/${id}/${files[thumbnail]}.webp`} alt="" className="absolute inset-0 size-full object-cover" /> {play === "circle" ? ( <> <span aria-hidden className={cn("absolute inset-0 bg-black/50 transition-colors group-hover:bg-black/30 group-focus-visible:bg-black/30", pop)} /> <span aria-hidden className="group/circle absolute top-1/2 left-1/2 flex size-[clamp(4.5rem,14cqw,9.375rem)] -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-white text-white" > <svg viewBox="0 0 24 24" fill="currentColor" className={cn("size-[30%] transition-transform group-hover/circle:scale-150 group-focus-visible:scale-150", pop)} > <path d="M7.5 4.8v14.4a.6.6 0 0 0 .9.5l11.6-7.2a.6.6 0 0 0 0-1L8.4 4.3a.6.6 0 0 0-.9.5z" /> </svg> </span> </> ) : ( <svg aria-hidden viewBox="0 0 68 48" className="absolute top-1/2 left-1/2 h-12 w-[68px] -translate-x-1/2 -translate-y-1/2"> <path d="M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z" className="fill-[#212121] opacity-80 transition-[fill,opacity] duration-100 ease-[cubic-bezier(0.4,0,1,1)] group-hover:fill-[#f00] group-hover:opacity-100 group-focus-visible:fill-[#f00] group-focus-visible:opacity-100" /> <path d="M 45,24 27,14 27,34" fill="#fff" /> </svg> )} </button> )} {overlay && ( <dialog ref={dialog} aria-label={title} onClose={() => setPlaying(false)} onClick={(event) => event.target === event.currentTarget && dialog.current?.close()} className="fixed inset-0 m-0 size-full max-h-none max-w-none items-center justify-center border-0 bg-transparent p-0 backdrop:bg-black/80 open:flex" > {/* Framer has no close button. This one shows only when the keyboard reaches it, so a keyboard user has a visible way out. */} <button type="button" onClick={() => dialog.current?.close()} className="sr-only cursor-pointer rounded-md bg-background px-3 py-2 text-sm font-medium text-foreground outline-none focus-visible:not-sr-only focus-visible:absolute focus-visible:top-5 focus-visible:right-5 focus-visible:ring-[3px] focus-visible:ring-ring/50" > {closeLabel} </button> {playing && player(id, title, "aspect-video w-[min(80vw,calc(90vh*16/9))] border-0")} </dialog> )} </div> ); }
Usage
import { LiteYouTube } from "@/components/ui/lite-youtube";
<LiteYouTube url="https://www.youtube.com/watch?v=YE7VzlLtp-4" title="Big Buck Bunny" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| url | string | — | A YouTube URL (watch, youtu.be, embed, shorts) or the bare video id. |
| title | string | — | The video's title: read to screen readers and used as the player's title. |
| playLabel | string | "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. |
| poster | string | — | Your own still instead of YouTube's thumbnail, so nothing is requested from YouTube before the click. |
| overlay | boolean | false | Play 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). |
| closeLabel | string | "Close video" | The name of the close button, which shows when the keyboard reaches it in the dialog. |
| className | string | — | 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.











