Accessibility, checking if user prefers reduced motion
Introduction
Animations on the web, love or loathe them, are everywhere. For a significant number of the worlds population this can have an impact on their accessibility needs.
How can simple motion cause problems?
Imagine if viewing animations were to cause you to lose your balance, this is possible with a malady know as vestibular disorder.
Dennis Gaebel / a11yproject.comYour Vestibular system is the sensory mechanism in the inner ear that detects movement of the head and helps to control balance.
Depending on the type and intensity of the animation it can also trigger epilepsy and migraines. To find out more read this list of vestibular disorders.
Configure your settings
Each relatively up-to-date Operating System has settings to allow reducing motion. In general this means turning it off altogether. Below are the instructions for Apple Mac Monterey.
- Open
System Preferences
and selectAccessibility
(the blue circle, 2nd row in the centre.) - Select
Display
under theVision
section. - Click the
Reduce motion
checkbox.
Mac OS Monterey System Preferences
Image Index
-
• Image 01
Mac OS Monterey System PreferencesBack to Images- • Image 02
Mac OS Monterey System Preferences > AccessibilityBack to Images- • Image 03
Mac OS Monterey System Preferences > Accessibility > DisplayAn example of pulsing animation (slowed down)
You can imagine after understanding the effects of vestibular disorder what the example below would do if speeded up. If you’ve already tried out configuring your settings to
reduce motion
it should be in a static state.Note: The preference setting depends on the browser honouring that choice.
The CSS code
The animation element is activated in a
div
with anid
ofreduce-motion-example
. In order to target and activate theprefers-reduced-motion
code we use;@media (prefers-reduced-motion: reduce) { #reduce-motion-example { animation: none; } }
The
@media
query will check for a preference and if set as above, will override theanimation
settings.While @media (prefers-reduced-motion)
will work in most cases, it is best for clarity and better support to add:reduce
.Target the inverse
There’s usually more than one way to do things. If the browser understands the
@media
query and the user has not set a preference forreduced motion
we can use the following code to only activate the animation usingno-preference
.@media (prefers-reduced-motion: no-preference) { #reduce-motion-example { animation: stretch 10s ease-out 0s alternate infinite; } }
In conclusion
Browsers are enabling Web Developers of modern websites more access to System Preferences allowing them to respect Users Preferences. This is a key factor to bear in mind moving forwards to make the web more accessible for everyone.
// End of Article
Article Information
Category: Technical
Topic: #AccessibilityFurther Reading
- A primer to vestibular disorders (a11yproject.com)
- An Introduction to the Reduced Motion Media Query (css-tricks.com)
- Designing Safer Web Animation For Motion Sensitivity (alistapart.com)
- MDN Documentation: prefers-reduced-motion (developer.mozilla.org)
- • Image 02