How to make Storybook Interactions respect user motion preferences

With this custom addon, you can ensure your workplace remains accessible to users with motion sensitivities while benefiting from Storybook’s Interactions.

Kendall Gassner
5 min readintermediate
--
View Original

Overview

The article discusses how to create a Storybook addon that respects user motion preferences, particularly for those with the 'prefers-reduced-motion' setting enabled. It provides a step-by-step guide to building this addon, ensuring that interactions are turned off by default for sensitive users while allowing all users to toggle interactions on or off.

What You'll Learn

1

How to create a Storybook addon that respects user motion preferences

2

Why it's important to consider motion preferences in user experience design

3

How to implement localStorage to manage user preferences in a React application

Prerequisites & Requirements

  • Basic understanding of React and Storybook
  • Familiarity with localStorage API(optional)

Key Questions Answered

How can I make Storybook interactions respect user motion preferences?
You can create a custom Storybook addon that checks the user's 'prefers-reduced-motion' setting and allows users to toggle interactions on or off. This ensures that users with motion sensitivities have a more comfortable experience while using Storybook.
What are the goals for the Storybook addon regarding motion preferences?
The goals include ensuring that users with 'prefers-reduced-motion' enabled have interactions off by default, providing a way to toggle interactions without changing system preferences, and allowing all users to toggle this feature.
What is the significance of the 'prefers-reduced-motion' setting?
The 'prefers-reduced-motion' setting is crucial for users with motion sensitivities, such as those with photosensitive epilepsy or vertigo, as it helps prevent disorientation and potential health risks caused by rapid animations.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Frontend
React
Used to build the Storybook addon for toggling interactions.
Web API
Localstorage
Used to store user preferences for interaction toggling.

Key Actionable Insights

1
Implement a toggle for interactions in your Storybook environment to enhance accessibility.
This is particularly important for users with motion sensitivities, as it allows them to control their experience without altering system settings.
2
Utilize the 'prefers-reduced-motion' media feature to automatically adjust animations based on user preferences.
By adhering to this setting, you can create a more inclusive user experience that respects individual accessibility needs.

Common Pitfalls

1
Ignoring user motion preferences can lead to a disorienting experience for sensitive users.
This oversight can cause discomfort or even health risks for users with conditions affected by motion, highlighting the importance of accessibility in design.

Related Concepts

Accessibility In Web Design
User Experience Best Practices
React Component Development