Components
- Accordion
- Action Bar
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context Menu
- Data List
- Date Picker
- Dialog
- Drawer
- Editable
- Field
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- Marquee
- Menu
- Native Select
- Number Input
- Pagination
- Popover
- Progress
- Prose
- QR Code
- Radio Group
- Rating
- Resizable
- Scroll Area
- Segment Group
- Select
- Separator
- Sheet
- Sidebar
- Signature Pad
- Skeleton
- Skip Nav
- Slider
- Spinner
- Status
- Steps
- Switch
- Table
- Tabs
- Textarea
- Timer
- Toast
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
1:1
Installation
pnpm dlx shadcn@latest add https://shark.vini.one/r/aspect-ratio.json
Usage
import { AspectRatio } from "@/components/ui/aspect-ratio";
<AspectRatio> <img src="/image.jpg" alt="Description" className="object-cover size-full" /> </AspectRatio>
Examples
Square
1:1
Portrait
9:16
Video
16:9
Responsive
Use [--ratio:*] with breakpoints to change the ratio at different screen sizes.
4:3 → 16:9 → 1:1
API Reference
AspectRatio
Main wrapper that preserves aspect ratio for its children using CSS.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
| Attribute | Description |
|---|---|
--ratio | 1 |