Layout
AspectRatio
Keeps its child at a fixed width-to-height ratio — media, maps, embeds. Uses native CSS aspect-ratio.
import { AspectRatio } from '@reactloom/ui';Examples
Ratios
1.00
1.33
1.78
import { AspectRatio, Center, SimpleGrid, Text } from '@reactloom/ui';
export default function Example() {
return (
<SimpleGrid columns={{ base: 1, sm: 3 }} gap="4" style={{ width: '100%' }}>
{[1, 4 / 3, 16 / 9].map((ratio) => (
<AspectRatio key={ratio} ratio={ratio}>
<Center style={{ background: 'var(--pl-color-accent-subtle)', borderRadius: 8 }}>
<Text tone="accent" weight="semibold">{ratio.toFixed(2)}</Text>
</Center>
</AspectRatio>
))}
</SimpleGrid>
);
}API reference
| Prop | Type | Default |
|---|---|---|
ratiowidth / height, e.g. 16 / 9. | number | 1 |
Accessibility
- Give images alt text and iframes a title.
Usage guidelines
Do
- Reserve space for media to avoid layout shift.
Don’t