Skip to content
Content Blocks docsv0.8.0Website

Docs / Elements

<content-video>

A video player for YouTube or self hosted files, built on Video.js.

Import it on its own, for a bundler
import '@content-blocks/js/components/content-video';

Examples

A YouTube video

The player loads a YouTube video in a Video.js player with its own controls.

Open on its own

Anatomy

Content goes into the component's slots, chosen with the slot attribute on each child.

flowchart LR
  root["#lt;content-video#gt;"]:::component
  root --> s0["<b>no slot (default)</b><br/>Default slot, same as content slot."]
  root --> s1["<b>slot=#quot;content#quot;</b><br/>Adjacent to no-js message for video. Usually not needed."]
  root --> s2["<b>slot=#quot;no-js-message#quot;</b><br/>Contents of no JS message."]
  root --> s3["<b>slot=#quot;playButton#quot;</b><br/>Play button contents."]
  root --> s4["<b>slot=#quot;poster#quot;</b><br/>Poster shown before video is played."]
  classDef component fill:#141413,color:#faf9f5,stroke:#141413
The slots of <content-video>
SlotWhat goes in it
(default)Default slot, same as content slot.
slot="content"Adjacent to no-js message for video. Usually not needed.
slot="no-js-message"Contents of no JS message.
slot="playButton"Play button contents.
slot="poster"Poster shown before video is played.

Properties

Set them as attributes. Those marked responsive take a value per breakpoint, separated by pipes and named or in order: 1|tablet=2 or 1|2. Seeresponsive values.

AttributeTypeDefaultDescription
autoplayBooleanfalseIf you're using this inside a content-overlay for example, you may want the video to play immediately on launch.
autoplay-muteBooleantrueSets whether or not an autoplaying video should be muted. By default autoplay videos will be muted.
classesresponsiveString–Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side".
controlsBooleantrueNot documented yet
fit-containerresponsiveString'false'Fit the container this video is placed in. When the video is used in an overlay or another place where the video will takeover the existing height, it is recommended to enable this option.
heightNumber9Not documented yet
methodSelect

youtube · html5

'youtube'Not documented yet
paddingresponsiveString–Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem".
play-button-aria-labelString'Play'Not documented yet
preloadString'metadata'Not documented yet
srcString''Supports YouTube and self hosted URLs.
typeString'video/mp4'Not documented yet
widthNumber16Not documented yet

Events and methods

sequenceDiagram
  participant Page
  participant C as content-video
  Page->>C: contentOverlayDeactivated event
What <content-video> listens for and what it tells the page