Intrinsic Size Transitions with interpolate-size and calc-size
How to animate height auto and other intrinsic sizing keywords in CSS, when to use interpolate-size versus calc-size(), limits, and fallbacks.
This page summarises Chrome Developers documentation on smooth transitions and animations between fixed lengths and intrinsic sizing keywords such as auto, min-content, max-content, and fit-content—a problem that historically pushed developers toward JavaScript or fragile max-height workarounds.
Use the interpolate-size property or the calc-size() function to enable smooth transitions and animations from lengths to intrinsic sizing keywords and back.
— Chrome Developers, Animate to height: auto; (and other intrinsic sizing keywords) in CSS
Why height: auto does not transition by default
Section titled “Why height: auto does not transition by default”People often want accordion panels, disclosure widgets, nav labels, or “show more” blocks to grow or shrink smoothly to their natural size. If you declare a transition on width or height and switch the property to an intrinsic keyword on :hover or when a class toggles, the change is usually abrupt—not animated.
Even though a transition is declared to transition the width property, and width: auto is declared on :hover, no smooth transition happens. Instead, the change is abrupt.
— Chrome Developers, Animate to height: auto; (and other intrinsic sizing keywords) in CSS
Browsers treat intrinsic sizing keywords as non-interpolatable unless you opt in (with interpolate-size) or wrap the keyword in calc-size().
interpolate-size: opt-in for keyword interpolation
Section titled “interpolate-size: opt-in for keyword interpolation”What interpolate-size does
Section titled “What interpolate-size does”The interpolate-size property controls whether animations and transitions may interpolate between lengths or percentages and intrinsic sizing keywords.
The CSS interpolate-size property gives you control over whether animations and transitions of CSS intrinsic sizing keywords should be allowed or not.
Its default value is numeric-only which does not enable interpolation. When setting the property to allow-keywords, you opt-in to interpolations from lengths to CSS intrinsic sizing keywords in the cases where the browser can animate those keywords.
— Chrome Developers, Animate to height: auto; (and other intrinsic sizing keywords) in CSS
| Value | Meaning |
|---|---|
numeric-only (default) |
An intrinsic-size keyword cannot be interpolated. |
allow-keywords |
A keyword and a length or percentage can interpolate when the engine supports it. |
Because interpolate-size inherits, enabling it on :root is the usual pattern:
:root { interpolate-size: allow-keywords;}Because the interpolate-size property is one that inherits, you can declare it on :root to enable transitioning to and from intrinsic sizing keywords for the entire document. This is the recommended approach.
— Chrome Developers, Animate to height: auto; (and other intrinsic sizing keywords) in CSS
Scope the opt-in to part of the page
Section titled “Scope the opt-in to part of the page”To avoid animating sizing keywords in a subtree that does not tolerate it, narrow the selector—for example only <main> and its descendants:
main { interpolate-size: allow-keywords;}See Animate to height: auto; (and other intrinsic sizing keywords) in CSS.
Why keyword interpolation is not on by default
Section titled “Why keyword interpolation is not on by default”The working group discovered that enabling this by default is not backward compatible because many style sheets assume that intrinsic sizing keywords (such as auto or min-content) cannot be animated.
— Chrome Developers, Animate to height: auto; (and other intrinsic sizing keywords) in CSS
The property is deliberately an opt-in. Unsupported browsers ignore it and sizing still updates; transitions to keywords simply jump instead of easing.
Supported sizing keywords in Chrome include auto, min-content, max-content, fit-content, and (for flex-basis) content.
Browser support for interpolate-size and calc-size() in the intrinsic sizes article: Chrome and Edge 129+; Firefox and Safari listed as not supported at the time that page was written.
calc-size(): math on intrinsic sizes
Section titled “calc-size(): math on intrinsic sizes”Syntax and when to use calc-size()
Section titled “Syntax and when to use calc-size()”calc-size() performs calculations on a single intrinsic basis in a defined, layout-safe way:
width: calc-size(<calc-size-basis>, <calc-sum>);The basis is typically one keyword (auto, min-content, and so on) or nested calc-size(). The second argument uses the size keyword to refer to the evaluated basis:
width: calc-size(auto, size);width: calc-size(min-content, size + 1rem);width: calc-size(max-content, size * 0.5);Another way to enable interpolation to and from intrinsic sizing keywords is to use the calc-size() function. It allows mathematics to be performed on intrinsic sizes in a safe, well-defined way.
— Chrome Developers, Animate to height: auto; (and other intrinsic sizing keywords) in CSS
For a plain transition from a fixed length to max-content with no math, interpolate-size: allow-keywords alone is enough; calc-size(max-content, size) gives the same visual result but adds syntax you must fall back from in older browsers.
Use calc-size() when you need offsets, clamps, rounding, or transitions between two calc-size() values that share the same basis—for example animating from min-content to min-content plus padding:
#element { width: min-content; transition: width 0.35s ease;}
#element:hover { width: calc-size(min-content, size + 10px);}Guidance in Calculate With Intrinsic Sizes states that for simple 0 to auto (or length to keyword) animations without arithmetic, you should use interpolate-size: allow-keywords, not calc-size() alone as a substitute.
Constraints inside calc-size()
Section titled “Constraints inside calc-size()”- Only one intrinsic keyword per
calc-size()call; you cannot mix keywords in one expression (unlike mistaken ideas such ascalc(max-content - min-content)). calc-size()represents an intrinsic size, not a bare length, so layout algorithms can treat it like the underlying keyword.- Percentages in the calculation resolve against the containing block, not against
size. For “150% of the intrinsic size”, usesize * 1.5instead ofsize + 50%.
Example with round():
p { width: calc-size(fit-content, round(up, size, 50px));}End-to-end pattern: expand and collapse with block-size
Section titled “End-to-end pattern: expand and collapse with block-size”The Animate to Intrinsic Sizes guide describes a reusable expansion pattern using logical properties:
-
Opt in on a parent (typically
:root):interpolate-size: allow-keywords. -
Set a fixed initial
block-size(orheight),overflow: hidden, and a transition on the sizing property. -
In the expanded state, set
block-size: auto(or another supported keyword).
:root { interpolate-size: allow-keywords;}
.expandable-container { block-size: 100px; overflow: hidden; transition: block-size 0.4s ease-out;}
.expandable-container.is-expanded { block-size: auto;}You can collapse in the opposite direction—from block-size: auto to 0—for dismissible alerts or similar UI. Pair collapsed-zero UI with accessibility: respect prefers-reduced-motion, and after transitionend you may set hidden on the element and sync aria-expanded on triggers (see Animate to Intrinsic Sizes).
Inline-size with calc-size() on hover
Section titled “Inline-size with calc-size() on hover”.badge { inline-size: 40px; overflow: hidden; white-space: nowrap; transition: inline-size 0.3s ease;}
.badge:hover { inline-size: calc-size(max-content, size + 20px);}Always declare a plain keyword or length before the calc-size() line so unsupported browsers keep a valid size:
inline-size: fit-content;inline-size: calc-size(fit-content, size + 2rem);interpolate-size vs calc-size(): which to choose
Section titled “interpolate-size vs calc-size(): which to choose”| Situation | Prefer |
|---|---|
Length ↔ auto / min-content / max-content / fit-content, no math |
interpolate-size: allow-keywords on :root or a subtree |
Offset, clamp, min() / max() / round() on an intrinsic basis |
calc-size() with fallbacks |
| Same intrinsic basis at both ends, but calculated end value | calc-size() |
In most cases, declare interpolate-size: allow-keywords on :root. It’s the easiest way to enable animation to and from intrinsic sizing keywords as it’s essentially a one-liner.
— Chrome Developers, Animate to height: auto; (and other intrinsic sizing keywords) in CSS
Using calc-size() obligates fallbacks or @supports checks; see Calculate With Intrinsic Sizes.
Feature detection examples:
@supports (inline-size: calc-size(auto, size + 0px)) { /* advanced sizing only when supported */}if (CSS.supports('inline-size', 'calc-size(auto, size + 0px)')) { // ...}Common use cases and limits
Section titled “Common use cases and limits”Notifications and @starting-style
Section titled “Notifications and @starting-style”Items with varying heights can enter with a height animation when the page opts in and each item uses height: auto with @starting-style:
:root { interpolate-size: allow-keywords;}
.item { height: auto;
@starting-style { height: 0px; }}Described in Animate to height: auto; (and other intrinsic sizing keywords) in CSS.
<details> open animation
Section titled “<details> open animation”With interpolate-size: allow-keywords, a height transition on <details> can animate opening; closing may need ::details-content (noted as upcoming in Chrome in the same article). Example pattern:
@supports (interpolate-size: allow-keywords) { :root { interpolate-size: allow-keywords; }
details { transition: height 0.5s ease; height: 2.5rem; }
details[open] { height: auto; overflow: clip; }}Performance
Section titled “Performance”Animating inline-size, block-size, width, or height triggers layout. Prefer these transitions only where content-sized motion is required; Calculate With Intrinsic Sizes notes that transform and opacity are cheaper when they can substitute.
Common mistakes
Section titled “Common mistakes”- Expecting
min-content→max-contentto animate without a length on one side. - Forgetting
interpolate-size: allow-keywordson an ancestor (defaultnumeric-onlyblocks interpolation). - Using only
calc-size()for simple0→autowheninterpolate-sizewould suffice and is simpler. - Relying on
size + 10%as “110% of content width” (percentages use normal percentage rules). - Omitting keyword fallbacks before
calc-size()declarations. - Ignoring
prefers-reduced-motionon expandable or dismissible components.
How to check this on your site
Section titled “How to check this on your site”-
Confirm in Chrome DevTools that
interpolate-size: allow-keywordsappears on:rootor the intended subtree in the Styles pane, and that expanded/collapsed states show the expected intrinsic keyword orcalc-size()on the sizing property. -
Toggle the expanded state (hover, class, or
<details open>) and verify in the Animations or Performance panel whetherheight,block-size, orinline-sizeinterpolates or jumps; compare against browser support in Animate to height: auto; (and other intrinsic sizing keywords) in CSS. -
In a browser without support, check that fallback lengths or keywords still produce a correct final layout (instant jump, no broken overflow).
-
Enable “Reduce motion” in the OS and confirm transitions on expandable UI are disabled if you added
@media (prefers-reduced-motion: reduce)as in Animate to Intrinsic Sizes. -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.