← All Exercises

Respect Reduced Motion in a Toast

basiccss~15min

Background

Vestibular disorders make large motion uncomfortable; reduced motion should keep state changes perceivable without sliding.

Problem

Build toast enter and exit transitions using transform and opacity, and remove the motion under prefers-reduced-motion without hiding the message or delaying its appearance.

Input

A toast element that appears and disappears.

Output

CSS transitions plus a reduced-motion override.

Sample tests

Sample 1

Input: Default motion settings
Expected: the toast transitions transform and opacity over 200ms using translateY

Sample 2

Input: prefers-reduced-motion: reduce
Expected: the media query sets transition-duration to 0.01ms and removes the translateY so the toast appears instantly

Your solution

Learning objective

Animate with transform and opacity, then provide a reduced-motion path that preserves content and state.