Attributes and Properties

Reference for all HTML attributes and JavaScript properties of the dotlottie-wc element, including src, autoplay, loop, speed, and mode.

The <dotlottie-wc> element is configured through HTML attributes and JavaScript properties. Attributes cover declarative configuration; properties cover values that cannot be expressed as attribute strings and access to the core player instance.

Attributes

Boolean attributes are enabled by adding the attribute without a value (e.g. <dotlottie-wc src="..." autoplay loop>).

AttributeTypeDefaultDescription
srcstringundefinedRequired. Source URL or path to the .lottie or .json animation file.
autoplaybooleanfalsePlays the animation automatically when loaded.
loopbooleanfalseLoops the animation.
speednumber1Playback speed of the animation.
datastring | ArrayBufferundefinedAnimation data as a Lottie JSON string, or as an ArrayBuffer for .lottie animations. ArrayBuffer data must be set via the JavaScript property, not the attribute.
segmentstringundefinedAnimation segment as a stringified array of two numbers: start frame and end frame (e.g. "[10, 50]").
mode"forward" | "reverse" | "bounce" | "reverse-bounce""forward"Animation play mode.
backgroundColorstringundefinedBackground color of the canvas. Accepts a 6-digit or 8-digit hex color string (e.g. "#000000FF").
themeIdstringundefinedID of the dotLottie theme to initially use.
animationIdstringundefinedID of the animation to load from a multi-animation .lottie file.
markerstringundefinedNamed lottie marker to play.
useFrameInterpolationbooleantrueDetermines whether the animation updates on subframes. false produces discrete frame-by-frame playback.
loopCountnumber0Number of times the animation loops before stopping. 0 loops infinitely when loop is present.
stateMachineIdstringundefinedID of the state machine to load on animation load.

Examples

<dotlottie-wc src="https://example.com/animation.lottie" autoplay loop speed="2"></dotlottie-wc>
<dotlottie-wc src="animation.lottie" mode="bounce" segment="[10, 50]" backgroundColor="#f0f0f0ff"></dotlottie-wc>
<dotlottie-wc src="multi.lottie" animationId="scene-2" themeId="dark-mode"></dotlottie-wc>

Properties

These properties are set or read via JavaScript on the element instance, not as HTML attributes.

PropertyTypeDescription
dotLottieDotLottie (read-only)The underlying core DotLottie instance, exposing all core methods and event listeners for programmatic control. Available after the element's load event fires.
renderConfigRenderConfigConfiguration for rendering the animation. See Render configuration.
layoutLayoutLayout configuration with fit and align properties. See Layout configuration.
themeDatastringRaw theme JSON string to apply directly, as an alternative to themeId.
stateMachineConfigStateMachineConfigSecurity configuration for the state machine. See StateMachineConfig.
workerIdstringWorker instance ID for the <dotlottie-worker-wc> variant. Elements sharing a workerId reuse one Web Worker.

Examples

Accessing the core instance:

const playerElement = document.querySelector("dotlottie-wc");
playerElement.addEventListener("load", () => {
  const coreInstance = playerElement.dotLottie;
  if (coreInstance) {
    coreInstance.play();
  }
});

Setting layout and renderConfig:

const player = document.querySelector("dotlottie-wc");
player.layout = { fit: "contain", align: [0.5, 0.5] };
player.renderConfig = { devicePixelRatio: 2 };

Setting stateMachineConfig:

const player = document.querySelector("dotlottie-wc");
player.stateMachineConfig = {
  openUrlPolicy: { requireUserInteraction: true, whitelist: ["https://example.com"] },
};
Last updated: August 6, 2026 at 11:58 AMEdit this page