Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input OTP
- Input Group
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- New Component
Elements
Charts
Icons
import { AspectRatio } from "@/components/ui/aspect-ratio";
export const AspectRatioDemo = () => (
<div className="w-full max-w-sm">
<AspectRatio ratio={16 / 9}>
<img src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" alt="Photo by Drew Beamer" className="h-full w-full rounded-md object-cover" />
</AspectRatio>
</div>
);Ratios
Common ratios for different media contexts.
1:1 — Square
4:3 — Classic
16:9 — Widescreen
With Placeholder
Use a bg-muted background to prevent layout shift while the image loads.
Props
AspectRatio
| Prop | Type | Default | Description |
|---|---|---|---|
ratio | number | 1 | Width divided by height — e.g. 16/9, 4/3, 1 |
className | string | — | Additional CSS classes |
Usage
import { AspectRatio } from "@/components/ui/aspect-ratio";
// 16:9 video thumbnail
<AspectRatio ratio={16 / 9}>
<img src="..." alt="..." className="h-full w-full object-cover" />
</AspectRatio>
// Square avatar
<AspectRatio ratio={1}>
<img src="..." alt="..." className="h-full w-full rounded-full object-cover" />
</AspectRatio>
// Placeholder while loading
<AspectRatio ratio={16 / 9} className="bg-muted rounded-md" />Specs
# Mint — Aspect Ratio Specs
## Component
- name: aspect-ratio
- file: registry/mint/aspect-ratio.tsx
- installs to: components/ui/aspect-ratio.tsx
- dependencies: radix-ui
- registryDependencies: none
## What is it
A layout utility that enforces a fixed width-to-height ratio on its content.
Use it for images, videos, maps, or any media where you need to prevent layout
shift before the content loads. The ratio is maintained regardless of the
container width. Prefer AspectRatio over manual padding hacks whenever fixed
proportions are required.
## Visual identity
Purely structural — AspectRatio itself carries no colour, radius, or shadow.
Visual character is entirely determined by the child content and any className
passed to the wrapper (e.g. bg-muted, rounded-md).
## Design tokens
No CSS variables consumed directly by the component. Callers typically apply:
--muted: oklch(0.96 0.02 155) / oklch(0.2 0.03 155) — placeholder background (bg-muted)
--radius: 1.25rem — rounded corners (rounded-md on wrapper or child)
## Conventions
- Always set object-cover on img children — object-contain causes letterboxing
- Use bg-muted as a placeholder background while the image is loading
- Wrap in a width-constrained parent (max-w-sm, w-full, etc.) — AspectRatio fills 100% of its container width
- For rounded corners: apply rounded-md and overflow-hidden to the AspectRatio wrapper, or rounded-md directly to the img child
- Do not nest AspectRatio inside flex/grid items without setting explicit widths
- Sub-components expose data-slot="aspect-ratio" for CSS targetingInstallation
$ npx shadcn add \https://gin-design.vercel.app/aspect-ratio