Aspect Ratio

Constrains content to a fixed width-to-height ratio.

16 / 9

Installation

npx lily-svelte@latest add aspect-ratio

Usage

<script lang="ts">
	import { AspectRatio } from '$lib/components/ui/aspect-ratio';
</script>
 
<AspectRatio ratio={16 / 9}>
	<img src="/cover.jpg" alt="Cover" class="size-full rounded-3xl object-cover" />
</AspectRatio>

Built by levish. The source code is available on GitHub.

Quiet by design.