Skip to content
LoidoltTheme 0.11.1
Svelte 5

Component

MediaEmbed

A YouTube or Vimeo video behind a click-to-load facade.

import { MediaEmbed } from '@loidolt/theme-svelte';

Example

Notes

  • Nothing is requested from the provider until the user presses play, and then only from its no-tracking host (youtube-nocookie.com, Vimeo with dnt=1).
  • No thumbnail is fetched from the provider by default, since that request alone would reveal the visit; pass a poster of your own, or embedThumbnail() if the request is acceptable.
  • Once loaded, focus moves into the player so keyboard users carry on where the button was. title names both the button and the iframe.

Props

Generated from the component source, so it cannot drift from the implementation.

MediaEmbed props
PropTypeDefaultNotes
title required string—Required: names the iframe and the play button.
class string—
eager booleanfalseLoad the provider's player straight away. By default a local facade stands in until the user presses play, so no third-party request happens before they choose to watch.
playLabel (title: string) => string(name) => `Play ${name}`
poster string—Still shown before the player loads. None is fetched from the provider by default — that request alone would tell them someone opened the page.
privacy booleantrueNo-tracking hosts: youtube-nocookie.com, Vimeo's dnt=1.
provider EmbedProvider—Or name the video directly.
ratio AspectRatioName | number | string'video'
ref bindableHTMLDivElement | nullnull
start number—Start offset in seconds. Read from the URL when it carries one.
unsupportedText string'This video link is not supported.'Shown when the URL is not a recognised YouTube or Vimeo link.
url string—A YouTube or Vimeo page, share or embed URL.
videoId string—

Plus the attributes of Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'>, forwarded to the root element.