AspectRatio
Reserve responsive media space before content loads.
Interactive preview
A responsive 16:9 canvas.
Usage
import { AspectRatio } from "@devvy-ui/react";
<AspectRatio ratio={16 / 9}><p>Reserved media canvas</p></AspectRatio>API reference
Native HTML attributes, className, style and a forwarded ref are supported. Component-specific props:
| Prop | Type | Default | Description |
|---|---|---|---|
| ratio | positive number | 16 / 9 | Width divided by height; invalid values fall back to a square. |
Accessibility & behavior
Platform Behavior & Guidelines
A CSS padding fallback reserves the ratio without measurement JavaScript. Label images/video accessibly inside it. Content fills the canvas; choose a sensible ratio for text. Style the wrapper or inner content through public classes.
Source ownership
Run npx @devvy-ui/cli init once in your React project, then add the source:
npx @devvy-ui/cli add aspect-ratioMake the source yours.
Start from the canonical implementation used by the package and registry. Change the code, keep the MIT notice, and build the behavior your project needs.
Edit your own copy. Downloaded source uses your changes; the component preview above uses the shipped version. Run the source installer first to include shared helpers.