SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

YouTubeEmbed

A YouTube player sized to its container.

View code
tsx
<div mix={[is("full"), maxIs("36rem")]}>
	<YouTubeEmbed videoId="dQw4w9WgXcQ" title="Rick Astley — Never Gonna Give You Up" />
</div>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add youtube-embed

Usage

typescript
import { YouTubeEmbed } from "@sdxc/ui";

Renders the player filling its container's inline axis at 16:9. The frame always sends the embedding page's origin as referrer, without which YouTube refuses to play.

Examples

Start at a time

View code
tsx
<div mix={[is("full"), maxIs("36rem")]}>
	<YouTubeEmbed
		videoId="dQw4w9WgXcQ"
		start={43}
		title="Rick Astley — Never Gonna Give You Up, from the chorus"
	/>
</div>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
videoIdstring—YesThe eleven-character id from the video's watch?v= or youtu.be/ URL.
startnumber—NoSeconds into the video the player starts at; zero or less starts at the beginning.
titlestring—YesThe frame's accessible name, announced before a reader enters the player.

Also accepts everything in Omit< TagProps<"iframe">, "src" | "title" | "allow" | "referrerpolicy" | "referrerPolicy" >.

@sdxc/ui

Can’t find it? Contact us