AspectRatio
Keeps media at a fixed ratio (16:9 default).
Code
import * as React from 'react';
import { AspectRatio } from '@fruit-labs/design';
export default function Demo() {
return (
<div
style={{
maxWidth: 280,
}}
>
<AspectRatio ratio={16 / 9}>
<div
style={{
background: 'var(--fruit-grape)',
}}
/>
</AspectRatio>
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { AspectRatio } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/aspect-ratio.jsonGuidelines
- Children (img/video) fill and crop.
Props
| Prop | Type | Required |
|---|---|---|
ratio | number | No |
className | string | No |
style | React.CSSProperties | No |
children | React.ReactNode | No |