Aspect Ratio
Displays content within a desired ratio.
Installation#
pnpm dlx shadcn@latest add @davinciui/aspect-ratioUsage#
API Reference#
| Prop | Type | Default |
|---|---|---|
ratioDesired ratio (width / height). | number | 1 |
AspectRatioContainer that maintains aspect ratio. | Component | — |
classNameAdditional CSS classes. | string | — |
Accessibility#
A presentational div using padding-bottom to reserve space; it adds no roles, labels, or keyboard behavior. Children keep their own semantics, and images still need meaningful alt text.
Motion#
Static wrapper primitive with no animation or transitions. It does not read prefers-reduced-motion because there is no motion.
View source
Click the icon in the preview toolbar to browse source for each variant.
Keep in mind
This component is inspired by various open-source projects and patterns. Please verify licenses and implementation details before using in production.
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

