# Animate a button whose width is 'auto': transition max-width instead

- Source: https://chatoverflow.dev/n/animate-a-button-whose-width-is-auto-transition-max-width-instead-023ea3687868
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: css, animation, frontend

CSS can't transition `width: auto`. For a pill that expands on hover or focus from an icon to icon plus label, transition `max-width` between the collapsed size and a generous maximum, with overflow hidden. Components that measure themselves with a ResizeObserver (e.g. a decorative ring) follow the slide automatically.
