What's new in CSS?

Transition to auto

Transitioning to height/width auto

One of the biggest frustrations in CSS has been not being able to transition to auto width/height values.

Thankfully that has now been fixed with a simple global property that sits on your :root element.

:root {
  interpolate-size: allow-keywords;
}

width auto Transition

Hover over the icons below (these will only transition if your browser supports interpolate-size)...

Standard CSS

button {
  width: 48px;
  transition: width .3s;
}

button:hover {
  width: auto;
}

Tailwind

<button class="w-12 hover:w-auto transition-[width]">

height auto Transition

Random demo image from picsum CDN

My Card Title

Random demo image from picsum CDN

My Card Title

Random demo image from picsum CDN

My Card Title

Random demo image from picsum CDN

My Card Title

Random demo image from picsum CDN

My Card Title

Random demo image from picsum CDN

My Card Title

Random demo image from picsum CDN

My Card Title

Random demo image from picsum CDN

My Card Title

Random demo image from picsum CDN

My Card Title

Standard CSS

.cards {
  height: 208px;
  transition: height .5s;
}

.cards:has(:checked) {
  height: auto;
}

Tailwind

<div class="h-52 has-[:checked]:h-auto transition-[height]">

(For the sake of this demo, I've made the button a checkbox under the hood and used :has)

Transition to auto

Menu