# YouTubeEmbed

> A performant YouTube video embed using lite-youtube-embed, powered by astro-embed.

The YouTubeEmbed component provides a performant way to embed YouTube videos. It
wraps the community
[`@astro-community/astro-embed-youtube`](https://astro-embed.netlify.app/components/youtube/)
package, which uses `lite-youtube-embed` under the hood --- rendering a static
poster image and only loading the YouTube iframe when the user clicks play.

```astro
---
import YouTubeEmbed from "astro-theme-university/components/YouTubeEmbed.astro";
---
```

## Props

<PropsTable component="components/YouTubeEmbed" />

## Examples

<Example label="Basic embed">
  <YouTubeEmbed id="dQw4w9WgXcQ" />
</Example>

<Example label="Embed with custom title">
  <YouTubeEmbed
    id="dQw4w9WgXcQ"
    title="Rick Astley - Never Gonna Give You Up"
  />
</Example>

## Notes

Always provide a descriptive `title` prop for accessibility.

The embed renders a clickable poster image on initial load. Only the small
`lite-youtube-embed` script that defines the custom element loads with the page;
YouTube's own iframe and player JavaScript load when the user clicks play.
