-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: #4298 loading components ignore prefers-reduced-motion #4341
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
base: master
Are you sure you want to change the base?
fix: #4298 loading components ignore prefers-reduced-motion #4341
Conversation
Add @media (prefers-reduced-motion: reduce) block to replace animated SVG mask-images with static equivalents for all loading variants (spinner, dots, ring, ball, bars, infinity). This respects user accessibility preferences for reduced motion by showing static visuals instead of animated SMIL SVGs when the user has enabled reduced motion in their OS or browser settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issue #4298 where loading component animations continue to run even when users have prefers-reduced-motion: reduce enabled. The fix addresses an accessibility issue for users with motion sensitivities by replacing animated SMIL SVGs with static equivalents when reduced motion is requested.
Key Changes:
- Added
@media (prefers-reduced-motion: reduce)block to override animated SVG masks with static versions - Implemented static SVG representations for all six loading variants (spinner, dots, ring, ball, bars, infinity)
- Static visuals maintain the same visual appearance as their animated counterparts, just without motion
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
saadeghi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
I don't think this is a good idea to completely disable the animations. With prefers-reduced-motion: reduce the loadings are not going to be understandable. mostly they will look like static circle icons which won't communicate to the user that it's an indicator that something is "loading".
prefers-reduced-motion: reduce should be about reducing the motion, not "disabling" it completely. In this case, slowing down the animation would be more helpful that disabling the animations.
…ed-motion Per maintainer feedback, completely disabling animations makes loading indicators unrecognizable. This update slows animations by 4x instead: - .loading/.loading-spinner: 2s→8s rotation, 1.5s→6s dasharray - .loading-dots: 1.05s→4.2s - .loading-ring: 1.8s→7.2s - .loading-ball: 0.8s→3.2s - .loading-bars: 0.8s→3.2s - .loading-infinity: 2s→8s This reduces motion while preserving the visual indication that something is loading.
|
@saadeghi Thanks for the feedback! You're absolutely right - I've updated the PR to slow down the animations by 4x instead of replacing them with static images. This way:
Let me know if you'd prefer a different slowdown factor (e.g., 2x or 3x instead of 4x). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @media (prefers-reduced-motion: reduce) { | ||
| .loading, | ||
| .loading-spinner { | ||
| @layer daisyui.l1.l2 { |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The layer specificity is inconsistent with the original .loading class definition. The original .loading class at line 2 uses @layer daisyui.l1.l2.l3, but this reduced-motion override uses @layer daisyui.l1.l2. This means the reduced-motion styles may not have the correct specificity to override the original styles. The layer should be daisyui.l1.l2.l3 to match the original .loading definition.
|
Fixed the layer specificity issue in commit e839bc6.
The selectors are now separated to use the correct layer for each class. |
Summary
Fixes #4298
Problem
Loading components (spinner, dots, ring, ball, bars, infinity) use animated SVGs with SMIL animations as
mask-image. These animations continue to run even whenprefers-reduced-motion: reduceis set because SMIL animations aren't affected by CSS media queries.This creates unnecessary rapid motion for users who have requested reduced motion due to vestibular disorders, epilepsy, or other motion sensitivities.
Solution
Added a
@media (prefers-reduced-motion: reduce)block that provides slowed-down versions (4x slower) of all animations instead of disabling them completely. This approach:prefers-reduced-motion: reducemeans "reduce" not "eliminate"Animation Duration Changes
.loading/.loading-spinnerrotation.loading/.loading-spinnerdasharray.loading-dots.loading-ring.loading-ball.loading-bars.loading-infinityHow to test
Or set reduced motion in your OS:
Notes
prefers-reduced-motioncorrectly via@media (prefers-reduced-motion: no-preference)blocks