Animate Height Auto Previewer
Browsers could not transition to height: auto until interpolate-size and calc-size() arrived in Chrome and Edge 129. This previewer runs both on a real disclosure panel. Pick a Technique, set the Duration and Easing, click the bar to watch the panel open to its content height, and copy CSS that also hides the closed panel from screen readers, skips the motion for people who ask for reduced motion, and still opens, without the animation, in browsers without the chosen feature. The address bar keeps your settings, so a link reproduces them.
How to Animate to Height Auto
- Pick a technique. In Technique, choose
interpolate-size(one declaration on:rootlets every height transition below it targetauto) orcalc-size()(only this one declaration animates). - Tune the motion. Drag Duration (100 to 1000 ms) and pick an Easing. ease-out-back (overshoot) opens slightly past the content height and settles back.
- Test it. Click the bar in the Live demo to collapse and expand the panel, and switch Demo content to see the same CSS land on short, long and list content.
- Copy the CSS. Click Copy CSS, give your element the
panelclass, and toggleopenon it from a button that also updatesaria-expanded. Copy link copies a link to these settings.
Why height: auto would not animate, and what changed
A transition needs two values it can interpolate between, and auto is not a length, so for years the browser simply jumped. Each workaround had a cost: measuring scrollHeight in JavaScript, animating max-height to a guessed number (the easing runs over the guess, not the real height), or a grid wrapper going from 0fr to 1fr. interpolate-size: allow-keywords is inherited, so declaring it on :root opts the whole page in. calc-size(auto, size) makes one value animatable and changes nothing else.
The copied CSS handles three details. visibility transitions with the height: it stays visible for the whole animation and turns hidden only once the panel is closed, which takes the content out of the accessibility tree and the Tab order. Engines without calc-size() drop the declaration as invalid, so a plain height: auto comes first as the fallback. And put padding on an inner element: padding on the panel itself is hidden when closed but still takes space at height: 0, leaving an empty gap.
The tests paste all 190 variants this tool generates (2 techniques, 5 easings, 19 durations) into a blank Chromium page. In each one the height follows the easing curve to within half a pixel at five points of the transition, lands on the content's exact height, ends hidden when closed, and does not animate under reduced motion. For a block element's height, min-content, max-content and fit-content give the same content height as auto, so the tool always opens to auto.