Theme
AspectRatio
Constrains child content to a specific aspect ratio
Start Here
Start from the smallest working snippet, then move to interactive examples and the full API contract below.
Styled quick start
Copy this entrypoint first. It includes the imports required to get the component on screen.
svelte
<script lang="ts">
import '@dryui/ui/themes/default.css';
import '@dryui/ui/themes/dark.css';
import { AspectRatio } from '@dryui/ui';
</script>
<AspectRatio>Content</AspectRatio>Import options
Root package
ts
import { AspectRatio } from '@dryui/ui'Per-component subpath
ts
import { AspectRatio } from '@dryui/ui/aspect-ratio'Customize
Use the interactive examples to see common variants, states, and composition patterns before building your own.
16:9 Aspect Ratio
16 : 9
svelte
<AspectRatio ratio={16 / 9}>
<img src="/placeholder.jpg" alt="16:9 image" class="aspect-media" />
</AspectRatio>4:3 Aspect Ratio
4 : 3
svelte
<AspectRatio ratio={4 / 3}>
<img src="/placeholder.jpg" alt="4:3 image" class="aspect-media" />
</AspectRatio>1:1 Square
1 : 1
svelte
<AspectRatio ratio={1}>
<img src="/placeholder.jpg" alt="Square image" class="aspect-media" />
</AspectRatio>Compose
The full API contract lives here: props, CSS variables, and the public data attributes you can target when styling.
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
ratio | number | 16 / 9 | — | — |
children | Snippet | — | ✓ | — |
Forwards <div> attributes via rest props. Common examples: id, style, role.