Best Practices for WCAG 2.1 Compliance

Introduction

This guide provides best practices for making Lottie animations accessible, along with a Voluntary Product Accessibility Template (VPAT) to help assess compliance. By following these guidelines, developers and designers can create Lottie animations that are not only visually appealing but also inclusive and accessible to a wider audience.

1. Perceivable

Text Alternatives

  • Provide text alternatives for Lottie animations using aria-label or aria-labelledby attributes.
  • Offer a concise description of what the animation conveys.

Time-based Media

  • Include a text description of the animation’s content and purpose.

Distinguishable

  • Ensure sufficient contrast for any text or crucial visual information in the animation.
  • Respect user preferences for reduced motion.

2. Operable

Keyboard Accessibility

  • Make sure all interactive elements in the animation can be controlled via keyboard.
  • Ensure the canvas element is focusable and can be navigated to using the keyboard.

User Controls

  • Implement play/pause and stop controls for the animation.
  • Allow users to adjust animation speed or disable autoplay.

Seizures and Physical Reactions

  • Avoid rapid flashing elements in animations (no more than three flashes per second).

Input Modalities

  • Ensure any visible labels on controls match their accessible names.

3. Understandable

Labels and Instructions

  • Clearly label any interactive elements in the animation.
  • Provide clear instructions for user interaction with the animation.

4. Robust

Compatibility

  • Ensure all interactive elements have appropriate ARIA roles and properties.
  • Use the appropriate ARIA role for the canvas element (e.g., role="img").

Implementation Example

<div role="region" aria-label="Lottie animation container">
<canvas
id="lottie-player"
width="300"
height="300"
aria-labelledby="animation-title animation-description"
role="img"
tabindex="0"
></canvas>
<h2 id="animation-title" class="visually-hidden">Animation Title</h2>
<p id="animation-description" class="visually-hidden">Detailed description of the animation.</p>
<div role="group" aria-label="Animation controls">
<button id="play-pause" aria-label="Play or pause animation">Play/Pause</button>
<button id="stop" aria-label="Stop animation">Stop</button>
</div>
</div>

Additional Considerations

  1. Provide alternatives for users who prefer reduced motion.
  2. Ensure that the animation doesn’t auto-play if the user has set their system preferences to reduce motion.
  3. Consider providing a static image alternative for users who cannot or prefer not to view animations.
  4. Regularly test with assistive technologies to ensure compatibility and proper functioning.

By following these best practices, you can significantly improve the accessibility of your Lottie animations and work towards WCAG 2.1 compliance.

Voluntary Product Accessibility Template (VPAT)

WCAG 2.1 Report

Table 1: Success Criteria, Level A

CriteriaConformance LevelRemarks and Explanations
1.1.1 Non-text Content (Level A)SupportsText alternatives are provided for Lottie animations.
1.2.1 Audio-only and Video-only (Prerecorded) (Level A)Not ApplicableLottie animations do not include audio.
1.2.2 Captions (Prerecorded) (Level A)Not ApplicableLottie animations do not include audio.
1.2.3 Audio Description or Media Alternative (Prerecorded) (Level A)SupportsText descriptions of animations can be provided.
1.3.1 Info and Relationships (Level A)SupportsProper markup techniques are used to structure content.
1.3.2 Meaningful Sequence (Level A)SupportsContent is presented in a meaningful order.
1.3.3 Sensory Characteristics (Level A)SupportsInstructions are not reliant on a single sensory ability.
1.4.1 Use of Color (Level A)SupportsColor is not used as the sole means of conveying information.
1.4.2 Audio Control (Level A)Not ApplicableLottie animations do not include audio.
2.1.1 Keyboard (Level A)SupportsAll functionality is operable through a keyboard interface.
2.1.2 No Keyboard Trap (Level A)SupportsKeyboard focus can be moved to and from components.
2.1.4 Character Key Shortcuts (Level A 2.1 only)Not ApplicableNo character key shortcuts are implemented.
2.2.1 Timing Adjustable (Level A)SupportsUsers can control animation playback.
2.2.2 Pause, Stop, Hide (Level A)SupportsControls to pause, stop, or hide animations are provided.
2.3.1 Three Flashes or Below Threshold (Level A)SupportsAnimations do not contain rapid flashing elements.
2.4.1 Bypass Blocks (Level A)Not ApplicableLottie player does not include blocks of repeated content.
2.4.2 Page Titled (Level A)Not ApplicableLottie player is a component, not a full page.
2.4.3 Focus Order (Level A)SupportsFocus order is logical and preserves meaning.
2.4.4 Link Purpose (In Context) (Level A)Not ApplicableLottie animations typically do not include links.
2.5.1 Pointer Gestures (Level A 2.1 only)Not ApplicableNo multi-point or path-based gestures are required.
2.5.2 Pointer Cancellation (Level A 2.1 only)SupportsFunctions are completed on the up-event.
2.5.3 Label in Name (Level A 2.1 only)SupportsVisible labels match their accessible names.
2.5.4 Motion Actuation (Level A 2.1 only)Not ApplicableFunctionality does not require device motion or user motion.
3.1.1 Language of Page (Level A)Not ApplicableLottie player is a component, not a full page.
3.2.1 On Focus (Level A)SupportsContext does not change on focus alone.
3.2.2 On Input (Level A)SupportsContext does not change on input alone.
3.3.1 Error Identification (Level A)Not ApplicableLottie player does not involve form submission.
3.3.2 Labels or Instructions (Level A)SupportsLabels are provided for user interface elements.
4.1.1 Parsing (Level A)SupportsHTML is well-formed and free of significant errors.
4.1.2 Name, Role, Value (Level A)SupportsNames, roles, and values can be programmatically determined.

Table 2: Success Criteria, Level AA

CriteriaConformance LevelRemarks and Explanations
1.2.4 Captions (Live) (Level AA)Not ApplicableLottie animations do not include live audio.
1.2.5 Audio Description (Prerecorded) (Level AA)Not ApplicableLottie animations do not include audio tracks.
1.3.4 Orientation (Level AA 2.1 only)SupportsContent is not restricted to a single display orientation.
1.3.5 Identify Input Purpose (Level AA 2.1 only)Not ApplicableLottie player does not collect user information.
1.4.3 Contrast (Minimum) (Level AA)SupportsSufficient contrast is ensured for text in animations.
1.4.4 Resize text (Level AA)SupportsText can be resized without loss of content or functionality.
1.4.5 Images of Text (Level AA)Not ApplicableLottie animations typically do not include images of text.
1.4.10 Reflow (Level AA 2.1 only)SupportsContent can reflow without loss of information.
1.4.11 Non-text Contrast (Level AA 2.1 only)SupportsVisual information used to indicate states has sufficient contrast.
1.4.12 Text Spacing (Level AA 2.1 only)Not ApplicableLottie animations typically do not include blocks of text.
1.4.13 Content on Hover or Focus (Level AA 2.1 only)SupportsAdditional content appearing on hover or focus is dismissible.
2.4.5 Multiple Ways (Level AA)Not ApplicableLottie player is a component, not a full website.
2.4.6 Headings and Labels (Level AA)SupportsHeadings and labels are clear and descriptive.
2.4.7 Focus Visible (Level AA)SupportsKeyboard focus indicator is visible.
3.1.2 Language of Parts (Level AA)Not ApplicableLottie animations typically do not include language changes.
3.2.3 Consistent Navigation (Level AA)Not ApplicableLottie player is a component, not a full website.
3.2.4 Consistent Identification (Level AA)SupportsComponents with the same functionality are identified consistently.
3.3.3 Error Suggestion (Level AA)Not ApplicableLottie player does not involve form submission.
3.3.4 Error Prevention (Legal, Financial, Data) (Level AA)Not ApplicableLottie player does not process legal or financial transactions.
4.1.3 Status Messages (Level AA 2.1 only)SupportsStatus messages can be programmatically determined.

This VPAT provides an overview of the accessibility compliance of the Lottie player component. It’s important to note that the actual compliance may vary depending on the specific implementation and content of the Lottie animations.