Skip to content

Aspect Ratio

SAspectRatio keeps its content (an image, video, map, or embed) at a fixed aspect ratio regardless of the container width, so the layout does not jump while media loads. The ratio prop is the width divided by the height.

Basic usage

With media

The content is usually an <img>/<video>/<iframe>: the component crops it to the frame (object-fit: cover) while keeping the proportions.

16:9 example

API

Props

NameTypeDefaultDescription
rationumber1Target aspect ratio (width / height). For example 16 / 9 for widescreen media, 1 for a square, 4 / 3 for a classic frame.

Slots

NameDescription
defaultContent with a fixed aspect ratio (image, video, map, placeholder).