Viana Kitv0.1.4

Components

Aspect Ratio

Constrains content to a specific aspect ratio. Use it to ensure images, videos, or embeds maintain their proportions across all screen sizes.

example.tsx

16:9 Aspect Ratio

Demo image

4:3 Aspect Ratio

Demo image

Import

tsx
import { AppAspectRatio } from "@/components/primitives/AppAspectRatio"

Common ratios

Pass any numeric expression to the ratio prop. Using division makes the intent clear at a glance.

RatioValueCommon use
16 / 91.777…Video, hero images, wide banners
4 / 31.333…Classic photo, older displays
1 / 11Square avatars, thumbnails
3 / 21.5Standard photography
9 / 160.5625Mobile / portrait video
tsx
{/* 16:9 video */}
<AppAspectRatio ratio={16 / 9}>
  <video src="/intro.mp4" className="h-full w-full object-cover" />
</AppAspectRatio>

{/* Square thumbnail */}
<AppAspectRatio ratio={1 / 1}>
  <img src="/avatar.jpg" alt="Avatar" className="h-full w-full object-cover" />
</AppAspectRatio>

API Reference

AppAspectRatio extends the Radix UI AspectRatio primitive.

PropTypeDefaultDescription
rationumber1The desired aspect ratio, expressed as width divided by height (e.g. 16/9).
classNamestringAdditional Tailwind classes merged via cn(). Prefer the wrapper pattern for reusable overrides.

Source

src/components/primitives/AppAspectRatio.tsx
import { AspectRatio } from "@/components/ui/aspect-ratio"

const AppAspectRatio = AspectRatio

export { AppAspectRatio }