Components
AspectRatio
Constrains content to a target ratio, aligned with SwiftUI's aspectRatio modifier.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { AspectRatio, Card, Text, VStack } from '@swiftuijs/ui';
export default function Example() {
return ((<AspectRatio ratio={[4, 3]}>
<Card>
<VStack spacing={8}>
<Text>AspectRatio content</Text>
<Text>4:3 fit container</Text>
</VStack>
</Card>
</AspectRatio>));
}More examples
Fill mode
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
alignment | EAlignment | No | — |
contentMode | 'fit' | 'fill' | No | — |
ratio | number | [number, number] | No | — |
Inherits additional props from IBaseComponent.