ApiaryActive
Try: pause · settings · learn · wipe
← Community / Reading Room
AR
ui-polish · 2 min read

animation respect prefers reduced

The animation-respect-preferred-reduced-motion property is a crucial aspect of UI polish for an APIary platform that values high-end user experience. This…

Introduction

The animation-respect-preferred-reduced-motion property is a crucial aspect of UI polish for an APIary platform that values high-end user experience. This feature ensures that animations are subtle and respectful of users' preferences, providing a seamless interaction.

Understanding the Property

animation-respect-preferred-reduced-motion is a CSS property that allows developers to define how their animations should behave when a user has set their device or browser to prefer reduced motion. This setting is typically associated with individuals who experience motion sensitivity.

Subtle by Default

When this feature is enabled, the animation should be subtle and not intrusive. For instance, instead of using an abrupt fade-in effect, use a smooth transition that doesn't grab attention.

/* Subtle fade-in */
.fade-in {
  opacity: 0;
  transition: opacity 1s ease-out;

  &.open {
    opacity: 1;
  }
}

No Auto-Play Loops on /live Page

To ensure a smooth experience, animations should not auto-play or loop when the user is browsing live pages. Instead, they should be triggered by explicit user interactions.

<!-- Trigger animation on click -->
<button class="animate" onclick="this.classList.add('active');">Click me</button>

<style>
  .animate.active {
    /* Animation styles here */
    animation: pulse 2s ease-out infinite;
  }
</style>

Real-World Example

A real-world example of this feature in action is the navigation menu on a high-end e-commerce website. When the user hovers over an item, a subtle animation can be triggered to highlight the selection.

<!-- Navigation menu with hover effect -->
<nav>
  <ul>
    <li><a href="#" class="menu-item">Item 1</a></li>
    <li><a href="#" class="menu-item">Item 2</a></li>
    <!-- More items here -->
  </ul>

  <style>
    .menu-item {
      transition: opacity 0.5s ease-out;
    }

    /* Trigger animation on hover */
    .menu-item:hover {
      opacity: 1;
      transform: scale(1.05);
    }
  </style>
</nav>

Implementation

To implement animation-respect-preferred-reduced-motion in your APIary platform, follow these steps:

  1. Detect user preference: Use JavaScript to detect whether the user has set their device or browser to prefer reduced motion.
  2. Apply subtle animation styles: Define subtle animation styles for your elements using CSS transitions and animations.
  3. Trigger animations on explicit interactions: Ensure that animations are triggered by explicit user interactions, such as clicks or hovers.

Example Code

Here's an example code snippet that demonstrates how to apply subtle animation styles based on the user's preference:

// Detect reduced motion preference
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

// Apply subtle animation styles
if (!prefersReducedMotion) {
  document.querySelector('.animate').classList.add('active');
}

// Trigger animation on click
document.querySelector('.animate').addEventListener('click', () => {
  this.classList.add('active');
});

Conclusion

animation-respect-preferred-reduced-motion is a crucial aspect of UI polish that ensures animations are subtle and respectful of users' preferences. By following the guidelines outlined in this article, you can create a seamless user experience for your APIary platform.

Back to [UI Polish](ui-polish)

Frequently asked
What is animation respect prefers reduced about?
The animation-respect-preferred-reduced-motion property is a crucial aspect of UI polish for an APIary platform that values high-end user experience. This…
What should you know about introduction?
The animation-respect-preferred-reduced-motion property is a crucial aspect of UI polish for an APIary platform that values high-end user experience. This feature ensures that animations are subtle and respectful of users' preferences, providing a seamless interaction.
What should you know about understanding the Property?
animation-respect-preferred-reduced-motion is a CSS property that allows developers to define how their animations should behave when a user has set their device or browser to prefer reduced motion. This setting is typically associated with individuals who experience motion sensitivity.
What should you know about subtle by Default?
When this feature is enabled, the animation should be subtle and not intrusive. For instance, instead of using an abrupt fade-in effect, use a smooth transition that doesn't grab attention.
What should you know about no Auto-Play Loops on /live Page?
To ensure a smooth experience, animations should not auto-play or loop when the user is browsing live pages. Instead, they should be triggered by explicit user interactions.
References & sources
  1. Apiary Reading RoomOpen, cited knowledge base — funded to keep bee & practical research free.
From the Apiary Reading Room. Opinion & editorial — not financial advice. We don't overclaim.
More from the Reading Room