Skip to content

Aspect Ratio

16 : 9

Constrains its content to a fixed width-to-height ratio (pure CSS aspect-ratio).

<script>
import AspectRatio from "@invisible-ui/svelte/AspectRatio.svelte";
</script>

In Elements:

<ds-aspect-ratio ratio="16/9">
<img src="/cover.jpg" alt="Harbour at dawn" />
</ds-aspect-ratio>
PropTypeDefaultDescription
rationumber1Width ÷ height (e.g. 16 / 9).

The content is the default slot (an image, video, map, …).

<AspectRatio ratio={16 / 9}><img src="/cover.jpg" alt="" /></AspectRatio>

In React:

<AspectRatio ratio={16 / 9}>
<img src="/cover.jpg" alt="" />
</AspectRatio>

Presentational — no ARIA of its own.