Animation

<wa-animation> Stable Since 2.0

Animate elements declaratively with nearly 100 baked-in presets, or roll your own with custom keyframes. Powered by the Web Animations API.

To animate an element, wrap it in <wa-animation> and set an animation name. The animation will not start until you add the play attribute. Refer to the properties table for a list of all animation options.

The animation will only be applied to the first child element found in <wa-animation>.

Examples

Link to This Section

Animations & Easings

Link to This Section

This example demonstrates all of the baked-in animations and easings. Animations are based on those found in the popular Animate.css library.

Using Intersection Observer

Link to This Section

Use an Intersection Observer to control the animation when an element enters or exits the viewport. For example, scroll the box below in and out of your screen. The animation stops when the box exits the viewport and restarts each time it enters the viewport.

Custom Keyframe Formats

Link to This Section

Supply your own keyframe formats to build custom animations.

Playing Animations on Demand

Link to This Section

Animations won't play until you apply the play attribute. You can omit it initially, then apply it on demand such as after a user interaction. In this example, the button will animate once every time the button is clicked.

Click me

Importing

Link to This Section

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/[email protected]/components/animation/animation.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/animation/animation.js';

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

import './webawesome/dist/components/animation/animation.js';

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

import WaAnimation from '@awesome.me/webawesome/dist/react/animation/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Methods

Link to This Section

Learn more about methods.

Events

Link to This Section

Learn more about events.

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