Web Awesome (ViUR)

Font Awesome
Try SSR Server-side rendering (SSR) generates component HTML on the server before the page loads, improving SEO and initial load time. Use the switch to see Web Awesome components render with and without SSR.
Search this website ⌘KCtrl+K Light Dark System Docs Select Color Scheme Default Awesome Shoelace Active Brutalist Glossy Matter Mellow Playful Premium Tailspin Docs Select Theme View Project on GitHub Star Project on GitHub
Start Components Docs Help
Web Awesome Font Awesome Build Awesome
Search this site… /
Try SSR Server-side rendering (SSR) generates component HTML on the server before the page loads, improving SEO and initial load time. Use the switch to see Web Awesome components render with and without SSR.
Light Dark System Docs Select Color Scheme Default Awesome Shoelace Active Brutalist Glossy Matter Mellow Playful Premium Tailspin Docs Select Theme

Getting Started

  • Installation
  • Usage
  • Forms
  • Localization
  • Frameworks
  • Using with AI
  • Figma Design Kit ProThis requires access to Web Awesome Pro
  • Server Rendering

Resources

  • Accessibility
  • Browser Support
  • Contributing
  • Patterns ProPatterns require access to Web Awesome Pro
  • Migrating from Shoelace
  • Visual Tests
  • Changelog
  • Help & Support

Theming & Utilities

  • Overview
  • Built-in Themes
  • Color Palettes
  • Design Tokens
  • Customizing & Theming
  • CSS Utilities

ViUR Components

  • Alert
  • Combobox
  • Pagination
  • Table Wrapper

Actions

  • Button
  • Button Group
  • Copy Button
  • Dropdown
    • Dropdown Item

Forms

  • Checkbox
  • Checkbox Group
  • Color Picker
  • Input
  • Known Date
  • Number Input
  • Radio Group
    • Radio
  • Rating
  • Select
    • Option
  • Slider
  • Switch
  • Textarea
  • Time Input
  • Data Grid Planned A Web Awesome Kickstarter stretch goal!

Layout

  • Accordion
    • Accordion Item
  • Card
  • Details
  • Dialog
  • Divider
  • Drawer
  • Page
  • Scroller
  • Split Panel

Navigation

  • Breadcrumb
    • Breadcrumb Item
  • Tab Group
    • Tab
    • Tab Panel
  • Tree
    • Tree Item

Feedback

  • Badge
  • Callout
  • Progress Bar
  • Progress Ring
  • Skeleton
  • Spinner
  • Tag
  • Tooltip

Media

  • Animated Image
  • Avatar
  • Carousel
    • Carousel Item
  • Comparison
  • Icon
  • Markdown
  • QR Code
  • Zoomable Frame

Data Viz

  • Advanced Usage

Helpers

  • Animation
  • Format Bytes
  • Format Date
  • Format Number
  • Include
  • Intersection Observer
  • Mutation Observer
  • Popover
  • Popup
  • Random Content
  • Relative Time
  • Resize Observer

Animation

  • Examples
  • Animations & Easings
  • Using Intersection Observer
  • Custom Keyframe Formats
  • Playing Animations on Demand
  • Importing
  • Slots
  • Attributes & Properties
  • Methods
  • Events
  • SSR
On This Page...
  • Examples
  • Animations & Easings
  • Using Intersection Observer
  • Custom Keyframe Formats
  • Playing Animations on Demand
  • Importing
  • Slots
  • Attributes & Properties
  • Methods
  • Events
  • SSR

Animation

<wa-animation>
Stable Helpers 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.

<div class="animation-overview">
  <wa-animation name="bounce" duration="2000" play><div class="box"></div></wa-animation>
  <wa-animation name="jello" duration="2000" play><div class="box"></div></wa-animation>
  <wa-animation name="heartBeat" duration="2000" play><div class="box"></div></wa-animation>
  <wa-animation name="flip" duration="2000" play><div class="box"></div></wa-animation>
</div>

<style>
  .animation-overview .box {
    display: inline-block;
    width: 100px;
    height: 100px;
    background-color: var(--wa-color-brand-fill-loud);
    margin: 1.5rem;
  }
</style>

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.

<div class="animation-sandbox">
  <wa-animation name="bounce" easing="ease-in-out" duration="2000" play>
    <div class="box"></div>
  </wa-animation>

  <wa-divider></wa-divider>

  <div class="controls">
    <wa-select label="Animation" value="bounce"></wa-select>
    <wa-select label="Easing" value="linear"></wa-select>
    <wa-input label="Playback Rate" type="number" min="0" max="2" step=".25" value="1"></wa-input>
  </div>
</div>

<script type="module">
  import { getAnimationNames, getEasingNames } from '/dist/webawesome.js';

  const container = document.querySelector('.animation-sandbox');
  const animation = container.querySelector('wa-animation');
  const animationName = container.querySelector('.controls wa-select:nth-child(1)');
  const easingName = container.querySelector('.controls wa-select:nth-child(2)');
  const playbackRate = container.querySelector('wa-input[type="number"]');
  const animations = getAnimationNames();
  const easings = getEasingNames();

  animations.map(name => {
    const option = Object.assign(document.createElement('wa-option'), {
      textContent: name,
      value: name,
    });
    animationName.appendChild(option);
  });

  easings.map(name => {
    const option = Object.assign(document.createElement('wa-option'), {
      textContent: name,
      value: name,
    });
    easingName.appendChild(option);
  });

  animationName.addEventListener('change', () => (animation.name = animationName.value));
  easingName.addEventListener('change', () => (animation.easing = easingName.value));
  playbackRate.addEventListener('input', () => (animation.playbackRate = playbackRate.value));
</script>

<style>
  .animation-sandbox .box {
    width: 100px;
    height: 100px;
    background-color: var(--wa-color-brand-fill-loud);
  }

  .animation-sandbox .controls {
    max-width: 300px;
    margin-top: 2rem;
  }

  .animation-sandbox .controls wa-select {
    margin-bottom: 1rem;
  }
</style>
<div class="animation-sandbox-combobox">
  <wa-animation name="bounce" easing="ease-in-out" duration="2000" play>
    <div class="box"></div>
  </wa-animation>

  <wa-divider></wa-divider>

  <div class="controls">
    <wa-combobox label="Animation" placeholder="Select animation..."></wa-combobox>
    <wa-combobox label="Easing" placeholder="Select easing..."></wa-combobox>
    <wa-input label="Playback Rate" type="number" min="0" max="2" step=".25" value="1"></wa-input>
  </div>
</div>

<script type="module">
  import { getAnimationNames, getEasingNames } from '/dist/webawesome.js';

  await customElements.whenDefined('wa-combobox');
  await customElements.whenDefined('wa-option');

  const container = document.querySelector('.animation-sandbox-combobox');
  const animation = container.querySelector('wa-animation');
  const animationName = container.querySelector('.controls wa-combobox:nth-child(1)');
  const easingName = container.querySelector('.controls wa-combobox:nth-child(2)');
  const playbackRate = container.querySelector('wa-input[type="number"]');
  const animations = getAnimationNames();
  const easings = getEasingNames();

  animations.forEach(name => {
    const option = document.createElement('wa-option');
    option.value = name;
    option.textContent = name;
    animationName.append(option);
  });

  easings.forEach(name => {
    const option = document.createElement('wa-option');
    option.value = name;
    option.textContent = name;
    easingName.append(option);
  });

  await Promise.all([animationName.updateComplete, easingName.updateComplete]);

  animationName.value = 'bounce';
  easingName.value = 'ease-in-out';

  animationName.addEventListener('change', () => (animation.name = animationName.value));
  easingName.addEventListener('change', () => (animation.easing = easingName.value));
  playbackRate.addEventListener('input', () => (animation.playbackRate = playbackRate.value));
</script>

<style>
  .animation-sandbox-combobox .box {
    width: 100px;
    height: 100px;
    background-color: var(--wa-color-brand-fill-loud);
  }

  .animation-sandbox-combobox .controls {
    max-width: 300px;
    margin-top: 2rem;
  }

  .animation-sandbox-combobox .controls wa-combobox {
    margin-bottom: 1rem;
  }
</style>

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.

<div class="animation-scroll">
  <wa-animation name="jackInTheBox" duration="2000" iterations="1"><div class="box"></div></wa-animation>
</div>

<script>
  const container = document.querySelector('.animation-scroll');
  const animation = container.querySelector('wa-animation');
  const box = animation.querySelector('.box');

  // Watch for the box to enter and exit the viewport. Note that we're observing the box, not the animation element!
  const observer = new IntersectionObserver(entries => {
    if (entries[0].isIntersecting) {
      // Start the animation when the box enters the viewport
      animation.play = true;
    } else {
      animation.play = false;
      animation.currentTime = 0;
    }
  });
  observer.observe(box);
</script>

<style>
  .animation-scroll .box {
    display: inline-block;
    width: 100px;
    height: 100px;
    background-color: var(--wa-color-brand-fill-loud);
  }
</style>

Custom Keyframe Formats

Link to This Section

Supply your own keyframe formats to build custom animations.

<div class="animation-keyframes">
  <wa-animation easing="ease-in-out" duration="2000" play>
    <div class="box"></div>
  </wa-animation>
</div>

<script>
  const animation = document.querySelector('.animation-keyframes wa-animation');
  animation.keyframes = [
    {
      offset: 0,
      easing: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
      fillMode: 'both',
      transformOrigin: 'center center',
      transform: 'rotate(0)',
    },
    {
      offset: 1,
      easing: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
      fillMode: 'both',
      transformOrigin: 'center center',
      transform: 'rotate(90deg)',
    },
  ];
</script>

<style>
  .animation-keyframes .box {
    width: 100px;
    height: 100px;
    background-color: var(--wa-color-brand-fill-loud);
  }
</style>

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
<div class="animation-form">
  <wa-animation name="rubberBand" duration="1000" iterations="1">
    <wa-button appearance="filled" variant="brand">Click me</wa-button>
  </wa-animation>
</div>

<script>
  const container = document.querySelector('.animation-form');
  const animation = container.querySelector('wa-animation');
  const button = container.querySelector('wa-button');

  button.addEventListener('click', () => {
    animation.play = true;
  });
</script>

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/webawesome@0.17.0/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.

Name Description
(default) The element to animate. Avoid slotting in more than one element, as subsequent ones will be ignored. To animate multiple elements, either wrap them in a single container or use multiple <wa-animation> elements.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Name Description Reflects
currentTime
Gets and sets the current animation time.
Type CSSNumberish
delay
delay
The number of milliseconds to delay the start of the animation.
Type number
Default 0
direction
direction
Determines the direction of playback as well as the behavior when reaching the end of an iteration. Learn more
Type PlaybackDirection
Default 'normal'
duration
duration
The number of milliseconds each iteration of the animation takes to complete.
Type number
Default 1000
easing
easing
The easing function to use for the animation. This can be a Web Awesome easing function or a custom easing function such as cubic-bezier(0, 1, .76, 1.14).
Type string
Default 'linear'
endDelay
end-delay
The number of milliseconds to delay after the active period of an animation sequence.
Type number
Default 0
fill
fill
Sets how the animation applies styles to its target before and after its execution.
Type FillMode
Default 'auto'
iterations
iterations
The number of iterations to run before the animation completes. Defaults to Infinity, which loops.
Type number
Default Infinity
iterationStart
iteration-start
The offset at which to start the animation, usually between 0 (start) and 1 (end).
Type number
Default 0
keyframes
The keyframes to use for the animation. If this is set, name will be ignored.
Type Keyframe[] | undefined
name
name
The name of the built-in animation to use. For custom animations, use the keyframes prop.
Type string
Default 'none'
play
play
Plays the animation. When omitted, the animation will be paused. This attribute will be automatically removed when the animation finishes or gets canceled.
Type boolean
Default false
playbackRate
playback-rate
Sets the animation's playback rate. The default is 1, which plays the animation at a normal speed. Setting this to 2, for example, will double the animation's speed. A negative value can be used to reverse the animation. This value can be changed without causing the animation to restart.
Type number
Default 1

Methods

Link to This Section

Learn more about methods.

Name Description Arguments
cancel() Clears all keyframe effects caused by this animation and aborts its playback.
finish() Sets the playback time to the end of the animation corresponding to the current playback direction.

Events

Link to This Section

Learn more about events.

Name Description
wa-cancel Emitted when the animation is canceled.
wa-finish Emitted when the animation finishes.
wa-start Emitted when the animation starts or restarts.

SSR

Link to This Section

Learn more about Server-Side Rendering (SSR).

<wa-animation> renders during SSR without causing layout shift, but won't play its animation until the component hydrates on the client. Playback is driven by the Web Animations API, which is only available in the browser.

Need a hand? Report a bug Ask for help
Go Make Something Awesome
Version 0.17.0 © Fonticons, Inc.
  • Terms
  • Privacy
  • Refunds
  • Core License
  • Pro License

Quick Links

  • Components
  • CSS Utilities
  • Theming
  • Using with AI
  • Changelog
  • Help & Support

Recent Searches

    D'oh! No results for “”

    Suggest on GitHub Ask on Discord
    Navigate Select
    Close Esc