Animating layout, or everything
- Forbidden
transition: height 200ms,transition: all 150ms, a keyframe that movestopormargin-left, Tailwind'stransition-all- Instead
- Animate
transformandopacity. To move,translate; to grow,scaleor a clip; to appear,opacity. Name the properties a transition covers:transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out).
What this rule looks like
Why this rule
width, height, margin, padding, top, left and their kin change layout, so the browser works out the position of everything around the element again on every frame, and on a slow phone the motion stutters. transform and opacity do not move anything else. all animates every property that changes, including a layout one someone adds next month, and nobody reading the rule can tell which. One accepted case: a disclosure opening to its content's height (P-11). Animate grid-template-rows from 0fr to 1fr on a wrapper, which the detector does not flag, or write the height transition with <!-- jig-allow G-162: a disclosure grows to its content -->. The detector warns on transition or transition-property naming all or a layout property; a keyframe step setting one; Tailwind's transition-all and transition-[<layout property>]. P-13's "Animate transform and opacity" becomes a pointer here.
- Kind
- Rule
- Section
- Things to avoid
- Group
- Motion
- Bucket
- hybrid
- Severity
- warning
- Detector
layout-motion- Since
- v0.23.0