layout-stability
Installation
SKILL.md
Layout Stability
A person aims at a control. When something moves under the pointer or the finger, they miss it, or they press what took its place. web.dev's Cumulative Layout Shift counts such moves. This skill goes past the metric where the metric is blind, and stops short of it where holding room would cost more than the move.
What may move
- A load, or an answer nobody pressed for, never moves what stands in view.
- A person's own press may move what stands below the control they pressed: they expect it, and web.dev counts no shift within 500 ms of a discrete input (a click, a tap, a key; not a scroll or a hover). The pressed control and everything above it hold, and the wait shows.
- Holding the tallest room of every state is not the cure: blank room under a short state costs more than the expected move. A shape matches the usual size of what comes, never its largest.
- Errors are rare. Build no machinery to hold room on a failure-and-retry path: on Try again the refusal goes and the ordinary wait shows, and a new failure shows the refusal again.
The cures
In this order of preference:
- Float it. What comes with no press stands over the page rather than in its flow: a toast, a floating button, a popover.
- Keep its room with a shape of the usual size, drawn in the parts the content will draw.
- Swap in place. The content and its placeholder share one grid cell: the placeholder keeps the room while there is no content and stays, unseen, under it after. The browser measures the room, never a number typed for one language. With several placeholders in the cell, the tallest keeps it.