svelte-youtube-embed
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

Youtube Video Embed

The package provides faster page load while embedding youtube videos since it loads the youtube thumbnail istead of the entire iframe.

The package will load the iframe and play the video only upong clicking the play button.

Installation

npm i -D svelte-youtube-embed

Usage

<script>
  import Youtube from "svelte-youtube-embed";
</script>

<Youtube id="EBtsu6naB8g" />

Default

<Youtube id="EBtsu6naB8g" />

With custom play button

<Youtube id="EBtsu6naB8g">
  <button>play</button>
</Youtube>

Using custom overlay

<Youtube
  id="EBtsu6naB8g"
  --overlay-bg-color="{overlayBGColor}30"
  --overlay-transition="all {overlayTransitionDuration}ms linear"
  />

Here the number `30` represents the opacity of `0.3`. Remove it for 100% opaqueness.

Using custom title colors

<Youtube
  id="KrSH82gg7BQ"
  --title-color={titleColor}
  --title-shadow-color="{titleShadowColor}30"
  --title-font-family={titleFontFamily}
/>

Alternative thumbnail

Some videos don't have custom thumbnail, so you can use this option to set the thumbnail to the default one.

<Youtube id="EBtsu6naB8g" altThumb={true} />

Disable animations

You can disable animation that is displayed when the play button is clicked by passing `animations` attribute.

<Youtube id="EBtsu6naB8g" animations={false} />

Custom thumbnail

Similar to how we can use custom play button, we can also use custom thumbnails.

Use slot="thumbnail" to a image/picture html tag and place it inside Yoututbe component.

<Youtube id="EBtsu6naB8g">
  <img
    slot="thumbnail"
    alt="A video on svelte"
    src="/path/image.jpg"
    style="width: 100%; height: 100%; object-fit: contain; object-position: center; background: red"
  />
  <!-- inline styles are optional -->
</Youtube>

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.4.1101latest

Version History

VersionDownloads (Last 7 Days)Published
0.4.1101
0.4.074
0.3.3762
0.3.220
0.3.127
0.3.064
0.2.929
0.2.80
0.2.63
0.2.50
0.2.40
0.2.313
0.2.23
0.2.174
0.2.00
0.1.70
0.1.205
0.1.110
0.1.100
0.1.90
0.1.86
0.1.60
0.1.50
0.1.40
0.1.23
0.1.13
0.1.00
0.0.160
0.0.150
0.0.140
0.0.130
0.0.123
0.0.110
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.32
0.0.20
0.0.10

Package Sidebar

Install

npm i svelte-youtube-embed

Weekly Downloads

1,192

Version

0.4.1

License

none

Unpacked Size

16.6 kB

Total Files

12

Last publish

Collaborators

  • webjeda