Skip to Content

Media Lit

Lit web components for Rixl images, adaptive HLS video playback, and infinite media feeds, with TypeScript APIs and included styles.

Web components for Rixl images, adaptive HLS video playback, and infinite media feeds. Use @rixl/media-lit in Lit, vanilla JavaScript, or any application that supports custom elements.

What you get

  • <rixl-video>: HLS playback, captions, quality selection, fullscreen, and picture-in-picture.
  • <rixl-image>: lazy loading and ThumbHash placeholders when available.
  • <rixl-feed>: vertical media feeds with pagination, looping, and automatic advancement.
  • Typed element properties and DOM events.
  • Included styles inside shadow DOM, with no Tailwind CSS setup.

These are the UI components used by the Rixl React, Vue, Svelte, Angular, and Astro adapters.

Install

npm install @rixl/media-lit

Lit 3 is included as a dependency. Use an ES-module-aware build tool and a browser with custom-element and shadow-DOM support.

Quick start: vanilla TypeScript

Connect before adding media elements to the document:

import "@rixl/media-lit/video";
import {connect} from "@rixl/media-lit/core";

await connect({
  baseUrl: "https://api.rixl.com",
  apiKey: "YOUR_PUBLIC_API_KEY",
});

const video = document.createElement("rixl-video");
video.videoId = "YOUR_VIDEO_ID";
video.muted = true;
video.style.cssText = "display:block;width:100%;aspect-ratio:16/9";
document.body.append(video);

Use credentials intended for browser access. Reuse the connection if your application already authenticates the shared @rixl/sdk client.

Attributes and properties

For declarative markup added after connecting, use the media ID attributes:

<rixl-video video-id="YOUR_VIDEO_ID" muted></rixl-video>
<rixl-image image-id="YOUR_IMAGE_ID" alt="Mountain lake at sunrise"></rixl-image>
<rixl-feed feed-id="YOUR_FEED_ID" muted></rixl-feed>

Import /image and /feed before using those tags. The regular HTML id attribute identifies the DOM element; image-id and video-id select Rixl media.

ElementID attributeJavaScript property
<rixl-image>image-idimageId
<rixl-video>video-idvideoId
<rixl-feed>feed-idfeedId

Boolean attributes follow HTML presence semantics: muted="false" still enables mute. Set a boolean property to false in JavaScript or omit the attribute. Property-only options such as volume are set in JavaScript.

Use in a Lit template

After initializing the SDK, render with Lit's property bindings:

import {html} from "lit";
import "@rixl/media-lit/video";

export const player = (videoId: string) => html`
  <rixl-video .videoId=${videoId} .muted=${true} .volume=${0.7} style="display:block;width:100%;aspect-ratio:16/9"></rixl-video>
`;

Events

import "@rixl/media-lit/video";

const video = document.querySelector("rixl-video");
video?.addEventListener("paused-change", (event) => {
  if (event instanceof CustomEvent) console.log(event.detail.paused);
});
video?.addEventListener("rixl-analytics", (event) => {
  if (event instanceof CustomEvent) console.log(event.detail.event);
});

Video state events include paused-change and loading-change; Feed emits mute-change and current-index-change. Image's loading-change detail is a boolean; Video's detail is {loading: boolean}.

Styling and rendering

Use normal CSS to size and position the hosts. Give images and videos an explicit height or aspect ratio, and feeds a height. The components include their internal styles in shadow DOM; application selectors do not reach internal controls.

Media contents render in the browser. For a documented server-rendering integration, use the React or Astro adapter; both render hosts on the server and initialize media in the browser.

Imports

ImportPurpose
@rixl/media-lit/imageRegister and export RixlImage
@rixl/media-lit/videoRegister and export RixlVideo
@rixl/media-lit/feedRegister and export RixlFeed
@rixl/media-lit/coreHeadless APIs, stores, utilities, and types
@rixl/media-litAll top-level media components

Each component subpath registers its tag automatically. An image-only subpath import excludes video, feed, and HLS code.