Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility, add support for prefers-reduced-motion #861

Open
aguscha333 opened this issue Oct 12, 2022 · 1 comment
Open

Accessibility, add support for prefers-reduced-motion #861

aguscha333 opened this issue Oct 12, 2022 · 1 comment

Comments

@aguscha333
Copy link

aguscha333 commented Oct 12, 2022

It would be a really good improvement if the library had more support for accessibility. One very important aspect when using animations is that not everyone wants to see them and for some it might have a negative impact.

One of the tools we can use to make this better is prefers-reduced-motion to bypass the transition all together.

Technically one can do this externally by getting that value with something like this hook use-reduced-motion and when it is true set the timeout to 0. But it would be much better if the library supported it by default and has a prop called ignorePrefersReducedMotion if people want to go out of their way to make it inaccessible.

I know this change would be breaking because it would change how the transitions work by default but it is very important for accessibility.

A more conservative approach would be to add the functionality turned off by default although less people would make use of it 😞.

In any case, adding some docs front and center about this feature should help educate people using the library and make products using this library more accessible.

@matt-greenfield-15
Copy link

I have achieved this for the CSSTransition component by using @media (prefers-reduced-motion) { in the CSS.
e.g.

.panel-enter {
  opacity: 0;
}

.panel-enter-active {
  opacity: 1;
  transition: opacity 200ms ease-out;
}

.panel-exit {
  opacity: 1;
}

.panel-exit-active {
  opacity: 0;
  transition: opacity 50ms ease-in;
}

/* 
  Users can set their OS to reduce motion, which will disable animations.
  on macOS, this is located in System Preferences > Accessibility > Display > Reduce motion
*/
@media (prefers-reduced-motion) {
  .panel-enter-active,
  .panel-exit-active {
    transition: none;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants