structyl

Aspect Ratio

stable

Constrains content to a desired width / height ratio.

Basic usage

16:9

Examples

Portrait and square

Use different ratios for portrait (4/5) and square (1/1) crops.

4:5
1:1

Media cards

AspectRatio keeps image, video and preview tiles stable across responsive widths.

Workspace desk
4:3 preview area

Features

  • Any ratio.
  • Works with images or any node.

Installation

bash
pnpm dlx structyl add aspect-ratio

API Reference

Aspect Ratio API reference

Full props, types, defaults.

View API
Aspect Ratio | structyl