swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
25.96k stars 8.85k forks source link

Disable animations for users with reduced motion preferences #10041

Open joe-op opened 1 week ago

joe-op commented 1 week ago

Is your feature request related to a problem?

Motion animations in CSS are not disabled when the media query prefers-reduced-motion is true (i.e., the user has indicated at the OS or some other level that they want animations disabled). The invalid input indicator in "Try it out" in particular has a prominent shake effect.

Describe the solution you'd like

Animations such as "shake" are disabled when prefers-reduced-motion is true.

@media(prefers-reduced-motion) {
  .class-typically-animated {
    animation: none;
  }
}

Describe alternatives you've considered

The media query can be overridden after importing swagger-ui CSS, but this is fragile and the end user depends on the developer of the API to implement it.

Additional context

https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion