Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Aspect Ratio for React and Tailwind

Wrapper that maintains aspect ratio for content.

1:1

Installation

bunx --bun shadcn@latest add https://kit.dev/r/aspect-ratio.json

Usage

import { AspectRatio } from "@/components/ui/aspect-ratio";
<AspectRatio className="w-full max-w-64 rounded-xl border bg-muted">
  <div className="flex size-full items-center justify-center">
    <span className="select-none text-muted-foreground text-xs">1:1</span>
  </div>
</AspectRatio>

Demos

Portrait

Responsive

Square

Video

API Reference

AspectRatio

div

PropType
AttributeType
CSS variableType