Your custom video popup can now play YouTube videos, not just Vimeo — and switching is almost effortless. This is a small update to the custom video popup we built together: same component, same configuration, just one new trick for grabbing the right YouTube URL. If you haven’t done the original build yet, start there and then come back here.
The one catch with YouTube is that you can’t simply copy the link from the address bar or the Share button — you need the proper embed URL, plus one tiny query parameter that lets our code control the player. Get that right and everything behaves exactly like the Vimeo version: it opens, plays, and pauses when you close it.
As a bonus, there’s a brand-new property for recoloring the play icon on the trigger, so it can match whatever palette your page is running.
How it works
Nothing about the popup itself changes. The component still reads the same video link property you configured last time — the only difference is what you feed it. For Vimeo you pasted a Vimeo URL; for YouTube you paste a YouTube embed URL. Same field, same component, and both can happily live on the same page (one popup on Vimeo, another on YouTube) with no conflict.
The reason a normal YouTube link doesn’t work is that it’s a watch link, meant for the browser, not for an iframe. YouTube’s real embed URL lives behind Share > Embed — and even there you don’t want the whole thing. You copy only the src, the part that runs from https up to the question mark, and drop that into the video link property.
One more piece makes the magic work: ?enablejsapi=1 appended to that URL. This switches on YouTube’s IFrame (JavaScript) API, which is what lets the popup’s code play and pause the video programmatically — so it autoplays when the popup opens and stops when it closes, exactly like the Vimeo behavior. Skip that parameter and the video will still load, but the popup loses that control.
The other new addition is a play-icon color property. It accepts any CSS color format — a keyword like white (the default), a hex value like #111, or an rgb() value — so the play button on your trigger can match your brand instead of always being white.
How to use it
-
Start from the existing build. This update assumes the custom video popup component is already on your page. If it isn’t, build the original first — you can clone the whole project below.
-
Grab the YouTube embed URL. Open the YouTube video, click Share, then click Embed (not Copy). In the embed code, copy only the
srcvalue — the part fromhttpsup to the question mark. -
Enable the JS API. Paste that URL into the same video link property on your popup, then add
?enablejsapi=1to the end so the popup can control playback. -
Publish and test. Open the live link and trigger the popup — the YouTube video plays, and closing it stops the video. Any Vimeo popups on the page keep working unchanged.
-
Recolor the play icon (optional). Set the play-icon color property to any CSS color — a keyword, a hex like
#111, or anrgb()value — then republish to see the trigger icon update.