Use a live status marker to compare transitions, keyframes, timing and reduced motion.
Motion can show that a value changed, that a control responded, or that an item moved from one position to another. A transition describes how a property changes between states. An animation describes a sequence of keyframes that can run without a separate style change. This guide uses both in a small connection-status example, then shows how to preserve the meaning when motion is reduced or disabled.
Pick the change a visitor should notice
The example shows a connection marker sliding from Idle to Ready when the visitor activates a button. The status also changes in words. The motion explains where the marker went, but the new state is understandable immediately without movement. Keep useful information in the page even if an animation fails, the browser is busy, or the visitor has chosen reduced motion.
Start with two concrete states before adding a transition. Give each state a meaningful class or attribute and check that it looks correct without any timing rule. Then choose which property should change gradually. A translation is a good fit for a moving marker. It affects its visual position without making surrounding text reflow. If changing the state requires other content to move, design that layout explicitly rather than assuming a transform will update occupied space.
Build a live example
Paste this example into the HTML editor. The button switches the marker between two positions and updates the visible status. A separate decorative dot runs a named animation and has no role in reporting the state.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Connection status motion practice</title>
<style>
body { max-width: 38rem; margin: 2rem auto; padding: 0 1rem; font: 1rem/1.6 system-ui; color: #10244a; }
.track { width: min(14rem,100%); height: 2.5rem; border-radius: 2rem; background: #dcefff; position: relative; }
.marker { position: absolute; inset-block-start: .25rem; inset-inline-start: .25rem; width: 2rem; height: 2rem; border-radius: 50%; background: #0053ad; transition: inset-inline-start 260ms ease-out, background-color 260ms ease-out; }
.track.ready .marker { inset-inline-start: calc(100% - 2.25rem); background: #19713a; }
.dot { display: inline-block; width: .65rem; height: .65rem; margin-inline-start: .4rem; border-radius: 50%; background: #19713a; }
.ready + p .dot { animation: signal 450ms ease-out both; }
@keyframes signal { from { opacity: .3; } to { opacity: 1; } }
button { min-height: 44px; padding: .4rem .8rem; font: inherit; }
:focus-visible { outline: 3px solid #843400; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .marker { transition: none; } .ready + p .dot { animation: none; } }
</style>
</head>
<body>
<main>
<h1>Connection status</h1>
<div class="track" aria-hidden="true"><span class="marker"></span></div>
<p><span id="state" role="status">Idle</span><span class="dot" aria-hidden="true"></span></p>
<button type="button" id="toggle">Toggle readiness</button>
</main>
<script>
const track = document.querySelector('.track');
const state = document.querySelector('#state');
document.querySelector('#toggle').addEventListener('click', () => {
state.textContent = track.classList.toggle('ready') ? 'Ready' : 'Idle';
});
</script>
</body>
</html>
Try it in the HTML editor
The example changes an inset to keep the marker’s endpoint proportional to the track width. In a production interface, a transform is often a better choice for movement that happens frequently, because browsers can often animate it without recalculating layout. Here the marker is positioned independently and the effect is small. Measure anything more complex before assuming animation performance is independent of how a property is rendered.
Read a transition declaration in order
A transition can name the property, duration, timing function, and delay. A duration specifies how long the change takes, while a delay specifies how long the browser waits before starting it. A timing function controls progress within the duration. Ease-out moves more quickly at first and slows near the end, which can feel responsive when an action changes a control. If a delay makes the interface seem unresponsive, remove it or update the textual state immediately as the example does.
Put the transition on the rule shared by both states. If you put it only on the ready state, the transition may animate in one direction and snap in the other. Try switching back before the first motion finishes. A transition can continue from the current interpolated position, which is useful when people interact quickly. If a property does not animate, inspect its old and new computed values and check whether the property supports the type of interpolation you expect.
Read keyframes as a timeline
The keyframes in the example start with a faint dot and finish with a solid dot. From and to represent the start and end of the timeline. Percentages let you describe intermediate states when needed. The animation name connects the declaration to its keyframes. If two parts of a stylesheet use the same keyframe name with different definitions, the later definition can change the earlier behaviour. Use names that make sense within the component rather than generic names that may collide.
The decorative animation runs once when the ready selector begins to match. The fill mode retains the final appearance for the duration of that applied animation. If an effect seems to jump back to its starting appearance, look at the value in the ordinary style as well as the keyframe value and fill mode. Do not rely on an animation retaining a value to establish the only source of important status. Keep the real state reflected in the markup or component style.
Respect motion preferences and verify both states
Start by removing both timing declarations and confirm that the words and marker still work. Restore the declarations, then enable reduced motion through your environment’s accessibility settings or the browser’s developer tools. Check that clicking still changes the status. On a page with several components, inspect which selector applies at the preference setting. A reduced-motion rule must have sufficient precedence to override an existing rule.
Test with the keyboard and switch the state several times. The update should never depend on a motion event finishing, because the browser might skip the effect when reduced motion is active. If you later need to coordinate expensive work with a transition, keep the actual state change independent and handle cancellation explicitly. Use the CSS editor to test the timing in isolation and consult MDN’s animation guide for the available properties.
Distinguish movement from layout and check actual performance
In the sample the moving circle is positioned inside a fixed track. Nothing else depends on where the circle sits, so its motion does not have to push other elements aside. If you move a card with a translation, however, its original space remains occupied in the layout. A card can overlap its neighbours even though the surrounding grid has not changed. Inspect both the position you see and the space the element reserves before deciding how to animate it.
For animation that happens often, compare using transform and opacity with changing a property that recalculates layout. Browser tools can record a performance trace and show whether frames become expensive. Test on a less powerful device if possible. A short animation with one small element may be inexpensive even if its property can trigger layout. A design applying similar changes to many items at once can behave differently. Let the evidence from the actual page guide the decision instead of assigning an assumed performance cost to every animation.
Try changing the marker’s duration to one second and activate the button twice quickly. The words report the new state immediately, while the circle can still be travelling. If that gap feels confusing, shorten the motion or remove it. Try a delay next. A delay may be useful for a decorative sequence but usually adds little to a simple button response. Restore the original duration after comparing the states. This experiment helps distinguish a slow interface from a fast interface with an unnecessary delay.
Avoid a timeline that matters outside the visual experience
A progress or success message should be understandable before decorative keyframes finish. If a real network operation is pending, show that it is pending. Change the message when the operation actually completes, rather than when a timer happens to run out. If a user can reverse or cancel an action, test the interface while several state changes are in flight. Keep the state and markup in agreement. The animation should follow those state updates and remain optional. A useful final test is to disable both transitions and animations and notice whether any necessary information disappears.
When testing a motion bug, record which action starts the effect and whether it fails on entry, exit, or both. A transition that works on exit only can indicate that the starting style was never rendered before the state changed. Check the elements while they are visible instead of adding a timeout until one device happens to work. For a keyframe effect that never starts, verify the animation name in the computed styles and confirm that the selector applies to the element you expected. A smaller isolated example makes these two cases easier to distinguish.