Web design and digital-business ideas grounded in real tasks.

Animating an expanding panel with CSS interpolate-size

Front-end developer comparing a collapsed and expanded web content panel on a desktop monitor.
AI-generated photographic illustration; not documentary photography.

An expanding panel knows its natural height after layout, but older CSS transitions could not smoothly interpolate between a length and auto. Developers often worked around that gap with guessed maximum heights. The interpolate-size property offers a more direct option where supported.

MDN documents allow-keywords as an opt-in for interpolation between a length or percentage and an intrinsic size. It does not make every pair of sizing keywords interchangeable: animating from one intrinsic keyword to another is a different problem.

Keep the opt-in close to the component

The property is inherited. Applying it to a component limits the change’s reach more clearly than enabling it across a large existing site. This small styling example assumes another part of the component controls the open state:

.panel {
  interpolate-size: allow-keywords;
  height: 0;
  overflow: clip;
  transition: height 180ms ease;
}
.panel.is-open { height: auto; }
@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}

This is the animation layer, not a complete accessible disclosure widget. A zero-height box can still contain focusable controls. The controller must also manage the trigger’s expanded state and prevent keyboard focus from entering collapsed content, using appropriate hidden or inert-state handling. Coordinate that handling with any closing transition.

Let the panel work without motion

MDN currently marks the feature as limited availability. In a browser that ignores the property, the content should still open and close, even if the change is immediate. Chrome’s intrinsic-size animation explanation provides additional implementation examples.

Try a panel with one sentence, another with several paragraphs, and one whose text wraps after zooming. Then navigate using only the keyboard. An animation that looks smooth with a short label can conceal a clipped paragraph or an unreachable button in a real layout.

Finally, test reduced-motion preferences and the browsers your audience uses. The success criterion is readable, reachable content in every state. Smooth movement is a finishing detail, and should not become a requirement for accessing the panel.