Animated Image

<wa-animated-image> Stable Since 2.0

A component for displaying animated GIFs and WEBPs that play and pause on interaction.

<wa-animated-image
  src="https://shoelace.style/assets/images/walk.gif"
  alt="Animation of untied shoes walking on pavement"
></wa-animated-image>

This component uses <canvas> to draw freeze frames, so images are subject to cross-origin restrictions.

Examples

WEBP Images

Both GIF and WEBP images are supported.

<wa-animated-image
  src="https://shoelace.style/assets/images/tie.webp"
  alt="Animation of a shoe being tied"
></wa-animated-image>

Setting a Width and Height

To set a custom size, apply a width and/or height to the host element.

<wa-animated-image
  src="https://shoelace.style/assets/images/walk.gif"
  alt="Animation of untied shoes walking on pavement"
  style="width: 150px; height: 200px;"
>
</wa-animated-image>

Customizing the Control Box

You can change the appearance and location of the control box by targeting the control-box part in your styles.

<wa-animated-image
  src="https://shoelace.style/assets/images/walk.gif"
  alt="Animation of untied shoes walking on pavement"
  class="animated-image-custom-control-box"
></wa-animated-image>

<style>
  .animated-image-custom-control-box::part(control-box) {
    top: auto;
    right: auto;
    bottom: 1rem;
    left: 1rem;
    background-color: deeppink;
    border: none;
    color: pink;
  }
</style>

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/webawesome@0.14.0/components/animated-image/animated-image.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/animated-image/animated-image.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/animated-image/animated-image.js';

To import this component for React 18 or below, use the following code:

import WaAnimatedImage from '@awesome.me/webawesome/dist/react/animated-image/index.js';

Slots

Learn more about using slots.

Attributes & Properties

Learn more about attributes and properties.

Events

Learn more about events.

CSS custom properties

Learn more about CSS custom properties.

CSS parts

Learn more about CSS parts.

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.

Need a hand? Report a bug Ask for help
    No results