On this page

Aspect ratio

When to keep a fixed ratio, common ratios and tokens.

Draft. Ported from the shadcn-vue Aspect Ratio. Not yet approved; the API may still change.

Aspect ratio keeps what is inside it at a fixed width-to-height ratio. The width follows its container; the height follows the ratio.

When to use

  • Images of different shapes in one grid, such as product photos, so the rows stay even.
  • Media that loads later, such as a video or a map, so the space is kept and the page does not jump while it loads.
  • Placeholders for a missing image, at the same size as the real one.

When not to use

  • For text. Text needs to grow when it wraps or when people zoom; a fixed ratio cuts it off.
  • For charts. Use the chart height tokens (visualization.chart-height).

Common ratios

Ratio Use
1 Product thumbnails, logos in a grid
4 / 3 Product photos
16 / 9 Videos, banners

Tokens

Aspect ratio has no visual values of its own. Style the content: images usually take radius.card and, on a light image, a color.border edge; a placeholder uses color.surface.subtle and an icon at size.icon.empty.