Core Web Vitals

Audit animation-induced layout shifts without breaking the interface

Test the complete component lifecycle before treating a transform as a finished CLS fix.

Two browser panels show a small card moving along a curved path while surrounding document blocks remain aligned.

A smooth animation can still move content in a way that contributes to CLS. Audit the properties that change and the layout before and after the effect, then test the complete interaction rather than judging a short recording by eye.

Start with a repeatable movement

Choose one component with a clear trigger: a notice entering the viewport, a card responding to hover, or a panel opening after a delayed response. Write down the page, viewport, initial state and exact action that reproduces the movement. Include whether the component appears automatically or follows a click. Keep the same content for the first comparison so that a different text length does not become an accidental second variable.

Record a performance trace that begins before the trigger and continues until the component settles. Inspect layout shift events around the movement and compare their timing with the animation. A moving element and a shift entry near each other are a useful lead, not proof that the animated rule is the only cause. A font swap, late image or inserted message can occur at the same time. Temporarily disable one effect and repeat the journey to narrow the explanation.

The official guidance on optimizing CLS explains why visual stability needs attention after loading as well as during it. Use CLS of 0.1 or less at the 75th percentile as the good field threshold. A local trace is diagnostic evidence from one run, not the site's field result. Keep that distinction visible in the issue you create.

Do not start by removing every animation from the site. First identify a reproducible component, its owner and its intended behavior. That gives the designer and developer something concrete to review and leaves unrelated motion available for separate investigation.

Separate geometry from visual movement

Inspect the computed styles at the beginning and end of the effect. Changing a margin, width, height or positional offset can make the browser update layout. Moving an element with a transform changes its visual presentation without using that movement to rearrange surrounding boxes. These are different contracts: one changes the space used by content, while the other changes how an existing box is drawn.

That distinction matters for a notification that must appear above an article. Translating the notification does not automatically reserve room for it. If the article must move down to make room, the design still needs an explicit layout decision. A stable reserved region may be appropriate; an overlay might be appropriate elsewhere. Do not select an overlay merely to hide a metric problem if it obscures a heading or a control.

Absolutely positioned elements also deserve inspection. Being outside normal document flow does not make every animated property harmless. Test the actual property change and its recorded result rather than assuming that a positioning mode guarantees stability. For a card that only needs a small visual lift, a transform is often a better candidate than changing its margin.

Review the outer wrapper and the inner animated element separately. A fixed space around a moving decoration can be stable even when the decoration changes appearance. Conversely, a transformed child cannot prevent its parent from collapsing when another rule removes the parent's height. Draw the two boxes in your issue and state which one owns the available space.

Replace broad transitions with explicit intent

Search the component's stylesheet for transition: all. It allows any eligible changed property to transition, including properties a later maintenance change introduces. An explicit list makes the movement easier to review. Keep that list beside the state rule so a reviewer can see whether the intended change is a color, a visual offset or actual geometry.

The following example lifts a card visually on hover or when focus is inside it. It is a presentation example, not a complete interactive card implementation. The card's normal layout space remains the same.

css
.card {
  transition: transform 160ms ease;
}

.card:hover,
.card:focus-within {
  transform: translateY(-4px);
}

@media (prefers-reduced-motion: reduce) {
  .card {
    transition: none;
  }

  .card:hover,
  .card:focus-within {
    transform: none;
  }
}

Keep the distance and duration as design choices, not performance targets. Test whether the visual lift overlaps a neighboring card, clips a shadow or moves an apparent click target too close to another control. A stable layout does not remove those usability questions. Use visible keyboard focus independently of motion so that the reduced-motion version remains understandable.

Avoid adding will-change to every card as a routine companion to this change. Layer promotion has costs and should respond to measured rendering problems. Start with the simpler explicit transition, record the result, and investigate any remaining painting or compositing issue separately. Changing more properties at once makes the cause of an improvement harder to establish.

Test the state change around the animation

A transition can be clean while the state update around it still shifts content. Check the moment before the effect starts, the frames during movement and the final frame. A banner may translate correctly and then remove a reserved wrapper. An expanding panel may finish its effect and replace a short loading label with a much taller result. Those changes belong to the same user journey even if they come from different rules.

Use a small test matrix instead of repeatedly watching the easiest case. Include the longest supported label, an empty response and an error message. Try the narrowest layout that the component supports and a zoomed view. Repeat opening and closing, because a stable entrance can conceal an unstable exit. If the effect is triggered automatically, wait through its actual delay rather than clicking a debug control that changes the timing.

Case Inspect Keep as evidence
Automatic entrance Space before insertion Trace and initial screenshot
Hover or keyboard focus Neighbors and focus visibility Both interaction paths
Delayed response Placeholder and final dimensions Slow-response recording
Close or dismiss Wrapper removal and scroll position Final settled state

Use this table as a starting point for the component, not a claim that every site needs the same cases. Add the states the product actually supports. Record which cases were tested and which remain outside the change, especially when a third-party embed controls its own content.

Respect motion preferences and interaction timing

Test with the operating system's reduced-motion preference enabled. A reduced-motion rule should leave the final state and the available controls clear. Removing a transition while preserving an unnecessary large translation may still be uncomfortable; decide whether the motion itself can be removed, as in the example. Check the result with keyboard navigation and confirm that focus does not disappear behind an overlay.

Do not rely on the recent-input exclusion as an excuse to keep disruptive motion. Some shifts soon after qualifying input are excluded from CLS, but hover and scrolling do not provide a blanket exemption for later changes. An asynchronous update can also arrive after the relevant interval. The useful question is whether the page remains predictable throughout the interaction, not whether a particular test happens to exclude a shift.

Keep feedback immediate when work continues in the background. Preserve a sensible space for status content where the design permits, and test both success and failure. Avoid inventing a fixed height that only fits the shortest English message. Translated labels, larger text and validation details can all expose an undersized region. Treat a clipped message as a failure even if the trace looks cleaner.

For a broader investigation of missing space, use the guide to stabilizing common sources of CLS. Animation work should complement that diagnosis rather than replace it. A single component can contain both an unsuitable transition and an image with no reserved dimensions.

Validate the change and keep the regression small

Compare the original and proposed component using the same browser, viewport, content and journey. Keep the trace files and note which rule changed. Check the recorded layout shifts, then inspect the screen and complete the task manually. A lower local CLS result is useful only alongside a working dismissal action, readable content and reachable controls.

Review rendering work as a separate outcome. An animation can avoid layout shifts yet still be expensive to paint, and a responsive interaction involves more than its visual effect. Do not claim that changing one CSS property fixes every Core Web Vital. Scope the result to the component and the evidence you collected. Where the site collects field data, compare equivalent populations after release and allow the reporting window to reflect the deployed change.

The distinction between field measurements and laboratory tests is especially useful for motion that appears only after a visitor has spent time on a page. Keep the reproduction journey with the component's documentation so future reviewers can repeat it. Include its reduced-motion behavior and a long-content case in normal regression checks.

Close the issue with a compact record: the trigger, the property replaced, the space-owning wrapper, the tested states and any remaining limitation. This makes a later style edit reviewable. The desired outcome is a component that keeps surrounding content stable and remains usable in every supported state, with measurements that describe exactly what was tested.

Related guides