Preserve control state when motion is reduced
Use `prefers-reduced-motion` to remove nonessential interaction animation while keeping the changed control state obvious through text, color, icon, or expanded content.
A reduced-motion preference should not make a control harder to understand. The common mistake is to think the animation is the proof of change, when the user actually needs the change itself to stay visible after the motion is gone. If a disclosure opens, a button activates, or a panel expands, the interface has to keep communicating that result in some way that does not depend on movement.
This article starts from a small disclosure example because it isolates the real decision: keep the interaction, remove the unnecessary transition, and preserve a clear state cue through text, icon, color, or expanded content. The CSS media query does the motion switch, but the component still owns the meaning of the change. That separation is what makes the behavior usable for readers who prefer less motion and for everyone else who benefits from a clearer state model.
The state change must survive without the animation
A reduced-motion preference is not a request to make the interface less understandable. It is a request to remove non-essential motion that could trigger discomfort or distract from the task. When a control changes from collapsed to expanded, or from inactive to active, the reader still needs a visible answer to the question: what changed?
That means the animation can be optional, but the state cue cannot be optional. If the only difference between the two states is that one slides, scales, or fades into place, the control becomes ambiguous when the motion is removed. The design has to carry the meaning in something more durable than movement.
The example in this article uses a disclosure button because it exposes the problem cleanly. A user activates the control, the panel expands, and the button label, icon, color, and expanded content all help signal the new state. The animation helps when it is available, but it is never the only carrier of meaning.
WCAG’s interaction-animation guidance is explicit about the boundary: motion triggered by interaction can be disabled unless it is essential to the information or functionality. The practical consequence is that the interface must still tell the truth when the motion disappears, not merely keep the same layout and hope the user infers the change.
// This controller models the state that a disclosure button exposes to its UI.
// The CSS below is meant to be applied in a browser; Node tests only prove the
// controller's state and motion-policy behavior, not browser media-query matching.
export const disclosureCss = `
.disclosure-panel {
max-height: 0;
opacity: 0;
overflow: clip;
transition: max-height 180ms ease, opacity 180ms ease;
}
.disclosure-panel[data-expanded="true"] {
max-height: 20rem;
opacity: 1;
}
.disclosure-button[data-expanded="true"] {
color: #075985;
}
@media (prefers-reduced-motion: reduce) {
.disclosure-panel {
transition: none;
}
}
`;
const labels = {
collapsed: { text: 'Show details', icon: '›' },
expanded: { text: 'Hide details', icon: '⌄' },
};
function validateMotionPreference(motionPreference) {
if (motionPreference !== 'no-preference' && motionPreference !== 'reduce') {
throw new RangeError(
'motionPreference must be "no-preference" or "reduce"',
);
}
}
/**
* Creates an interaction controller for a disclosure control.
* `motionPreference` represents the result of the browser/OS preference check.
*/
export function createDisclosure({ motionPreference = 'no-preference' } = {}) {
validateMotionPreference(motionPreference);
let expanded = false;
function view() {
const label = labels[expanded ? 'expanded' : 'collapsed'];
const motionReduced = motionPreference === 'reduce';
return {
button: {
ariaExpanded: String(expanded),
dataExpanded: String(expanded),
text: label.text,
icon: label.icon,
color: expanded ? '#075985' : '#1f2937',
},
panel: {
hidden: !expanded,
dataExpanded: String(expanded),
transition: motionReduced
? 'none'
: 'max-height 180ms ease, opacity 180ms ease',
},
};
}
return {
dispatch(command) {
if (command !== 'toggle') {
throw new RangeError('Unsupported command: ' + command);
}
expanded = !expanded;
return view();
},
view,
};
}
SourcesMDN: prefers-reduced-motion (opens a new tab)WCAG 2.2 Understanding SC 2.3.3 Animation from Interactions (opens a new tab)
`prefers-reduced-motion` changes which rule wins
The media feature detects whether the user has enabled a reduced-motion preference on the device or in the browser. In CSS terms, it lets you branch the final computed styles so the same component can use different motion policies without JavaScript deciding for every interaction. That makes it the right tool for a style-level preference, because the browser can apply it consistently to the whole page or component subtree.
The important detail is cascade order. A reduced-motion rule is not magical by itself; it wins because it uses the same selector specificity and appears later in source order. In the MDN example, the regular animation becomes a toned-down dissolve when the preference is on, and the visual difference is still tied to the same element. That is a useful pattern because it changes the motion policy without changing the component's meaning.
For interaction design, the question is not whether motion exists at all. It is whether the motion is doing work that only motion can do. If the work is merely decorative, remove it. If the work is to help the user notice a new state, keep another visible cue in place and let the animation become an enhancement rather than the proof.
This separation matters because the CSS query only answers one question: should we reduce motion? It does not tell you which parts of the interface should be re-labeled, recolored, expanded, or made persistent. That is still the component author’s job, and it is where many reduced-motion implementations fail.
A persistent cue is different from a motion cue
The cleanest repair is to separate two jobs that often get bundled together. The first job is the transition: animate the panel or icon so the change feels responsive. The second job is the state cue: make the new state legible after the transition ends, and legible even when the transition never happens. If those jobs are fused, removing animation can erase the only meaningful distinction.
In the supplied controller, the button text changes from “Show details” to “Hide details,” the icon flips from a chevron-like marker to an expanded marker, and the color changes when the section is open. The panel also gets a data attribute and visibility state that the UI can read directly. Those changes are not motion. They are persistent facts about the current state.
That is the central design rule here: motion can introduce or emphasize the change, but the interface must still encode the result in stable properties. A reduced-motion user should not need to watch the component animate to understand whether it opened or closed. The post-activation state should still be obvious if the reader sees only the end frame.
WCAG’s wording allows essential motion, but it warns that unnecessary animation from interactions can be disabled. That means your component should treat animation as a presentation choice layered on top of a semantic state, not as the state itself.
SourcesWCAG 2.2 Understanding SC 2.3.3 Animation from Interactions (opens a new tab)
The example keeps one control and one decision
The example is deliberately small: one disclosure control, one panel, and one motion preference input. That is enough to show the policy boundary without turning the article into a framework survey. The component stores the expanded state once, and the view reads that state to choose the text, icon, color, visibility, and transition. The CSS and the controller both point at the same underlying condition.
The key choice is that the reduced-motion branch removes the transition rather than replacing the whole interaction. The button still toggles. The panel still expands and collapses. What changes is the motion policy: the interface stops animating the change, but it does not stop exposing the changed state. That keeps the user in control while preserving the meaning of the action.
This is also why the article does not treat reduced motion as a separate feature mode. The control is the same control in both cases. Only the presentation policy changes. That matters because users with reduced-motion preferences should not get a different product; they should get the same product with a safer and less distracting transition strategy.
The controller’s `view()` output makes the distinction easy to test. You can assert that the animation policy changes to `none` while the expanded state remains `true`, or that the collapsed state still says “Show details” after toggling back. Those are not style guesses; they are concrete state checks.
SourcesMDN: prefers-reduced-motion (opens a new tab)WCAG 2.2 Understanding SC 2.3.3 Animation from Interactions (opens a new tab)
A weaker fix removes motion but hides the result
A common incomplete fix is to disable the animation and leave the rest untouched. That sounds respectful, but it often leaves the user with a control whose only visible difference is a sudden layout change. The interface may technically obey the preference, yet still feel cryptic because nothing persistent explains what happened. Motion disappeared, but the message did not replace it.
Another partial fix is to keep the text static and rely on the panel opening as proof. That can work only if the panel itself contains enough immediately visible content to make the state obvious. In many controls, the visible chrome of the control matters just as much as the content below it. If the button still says the original label after expansion, the user has to infer the state from context instead of reading it directly.
The article’s example avoids both problems by pairing the motion policy with state labels. The button changes text, the icon changes shape, the color changes, and the panel exposes the expanded content. Any one of those can help, but the combination makes the state unmistakable even when the transition is removed entirely. That is what survives the preference change.
This is the right standard for reduced motion: ask what the end state has to communicate, then make sure that message is available without animation. If the answer depends on watching the transition happen, the component is still too dependent on motion.
The tests prove the state policy, not a browser preference toggle
The supplied Node tests check the controller’s public behavior. They confirm that the normal interaction path keeps the transition string, that the reduced-motion path removes it, and that the button and panel still switch into a clearly expanded state. They also verify the collapsed state after a second toggle, which matters because a one-way demonstration would not prove that the state label remains reliable in both directions.
Those tests are intentionally narrow. They do not pretend to prove that every browser on every operating system will emit the same media query result. They also do not measure vestibular impact, and they do not claim accessibility compliance by themselves. What they do prove is that the component’s internal contract keeps the visible state separate from the motion policy.
That distinction is important because the article’s promise is architectural, not cosmetic. The code can be read and tested as a policy boundary: reduced motion removes the animation, while the UI still tells the user whether the disclosure is open or closed. The tests establish that the state labels, icon, visibility, and transition policy do not collapse into one ambiguous signal.
In practice, that makes the example useful as a regression boundary. If a later edit removes the label change or reintroduces motion as the only meaningful difference, the tests fail for the right reason: the control no longer makes its state clear enough without the animation.
import test from 'node:test';
import assert from 'node:assert/strict';
import { createDisclosure } from './main.mjs';
test('toggle expands with the normal interaction transition and a persistent changed label', () => {
const disclosure = createDisclosure({ motionPreference: 'no-preference' });
const state = disclosure.dispatch('toggle');
assert.equal(state.panel.hidden, false);
assert.equal(state.panel.transition, 'max-height 180ms ease, opacity 180ms ease');
assert.equal(state.button.ariaExpanded, 'true');
assert.equal(state.button.text, 'Hide details');
assert.equal(state.button.icon, '⌄');
assert.equal(state.button.color, '#075985');
});
test('reduced motion removes the interaction transition while retaining the expanded state', () => {
const disclosure = createDisclosure({ motionPreference: 'reduce' });
const state = disclosure.dispatch('toggle');
assert.equal(state.panel.transition, 'none');
assert.equal(state.panel.hidden, false);
assert.equal(state.panel.dataExpanded, 'true');
assert.equal(state.button.ariaExpanded, 'true');
assert.equal(state.button.text, 'Hide details');
assert.equal(state.button.color, '#075985');
});
test('a second reduced-motion toggle collapses without losing the clear collapsed state', () => {
const disclosure = createDisclosure({ motionPreference: 'reduce' });
disclosure.dispatch('toggle');
const state = disclosure.dispatch('toggle');
assert.equal(state.panel.transition, 'none');
assert.equal(state.panel.hidden, true);
assert.equal(state.button.ariaExpanded, 'false');
assert.equal(state.button.text, 'Show details');
assert.equal(state.button.icon, '›');
});
test('unsupported motion-preference input is rejected instead of silently choosing a policy', () => {
assert.throws(
() => createDisclosure({ motionPreference: 'sometimes' }),
/motionPreference must be/,
);
});
test('unsupported commands do not alter the disclosure state', () => {
const disclosure = createDisclosure({ motionPreference: 'reduce' });
assert.throws(() => disclosure.dispatch('open'), /Unsupported command: open/);
assert.equal(disclosure.view().button.ariaExpanded, 'false');
assert.equal(disclosure.view().panel.hidden, true);
});
SourcesWCAG 2.2 Understanding SC 2.3.3 Animation from Interactions (opens a new tab)
Use this pattern when motion is decorative or supportive
This approach works best when the motion is helpful but not essential. Disclosure panels, button press states, menu reveals, accordions, and similar interface changes usually fit that description. If the animation merely helps the user notice the change, reduced motion should remove it while the state cue stays visible. The interface remains familiar, but the motion no longer drives comprehension.
The pattern is not enough if the animation itself carries the meaning. For example, if a gradual transition is the only way the user can track a change in data value, or if motion conveys a sequence that has no alternative representation, then the design needs a different accessibility strategy. In that case, the motion may be essential, or the information may need a separate textual or structural form.
The practical test is simple: after the animation is removed, can a reader still tell what happened? If the answer is yes, the state cue is doing its job. If the answer is no, the animation is doing too much work. A good reduced-motion implementation never asks the user to infer the state from the very movement that was supposed to be reduced.
That is why the article favors text, color, icon, and expansion state over movement alone. Those are durable cues. They survive the operating-system preference, the browser’s media query result, and the end of the transition itself. The component becomes easier to understand for everyone, and safer for readers who need less motion.
SourcesMDN: prefers-reduced-motion (opens a new tab)WCAG 2.2 Understanding SC 2.3.3 Animation from Interactions (opens a new tab)
Carry the preference into your own components, not just your stylesheet
The durable lesson is to model the control’s state separately from its animation policy. The state decides whether the panel is open, which label appears, which icon is shown, and whether the button looks active. The motion policy decides whether the transition runs. Once those responsibilities are separated, the reduced-motion branch becomes a small, predictable override instead of a special case that risks changing behavior.
That separation also keeps the UI honest about what the user actually did. An opened panel should look open even if the transition never plays. A collapsed panel should still read as collapsed after a second toggle. The user should never need to remember the previous frame to know the current one. That is the difference between a transition and a state cue.
If you apply the pattern to a different control, the details may change, but the rule does not. Replace the animation with the best non-motion state signal you have: text, color, icon, expanded content, or another stable cue that already belongs to the component. Then remove only the motion that is non-essential. The user still gets the same interaction, just with less movement.
The result is not a lesser interface. It is a more explicit one. The control still changes, the state still survives, and the reader can still understand the outcome even when the operating system says motion should be reduced.
SourcesMDN: prefers-reduced-motion (opens a new tab)WCAG 2.2 Understanding SC 2.3.3 Animation from Interactions (opens a new tab)


