Components
- Accordion
- Action BarUpdated
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- BadgeUpdated
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- CalendarUpdated
- CardUpdated
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context MenuUpdated
- Data List
- Date Picker
- DialogUpdated
- DrawerUpdated
- Editable
- FieldUpdated
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- MarqueeUpdated
- Menu
- Native Select
- Number InputUpdated
- 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
- TableUpdated
- Tabs
- Textarea
- TimerUpdated
- ToastUpdated
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
Hooks
Aspect Ratio
Wrapper that maintains aspect ratio for content.
1:1
Installation#
pnpm dlx shadcn@latest add @shark/aspect-ratio
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.
16:9 → 1:1
You can use breakpoint utilities to change the aspect ratio at different screen sizes.
md:[--ratio:16/9] lg:[--ratio:16/9]
API Reference#
AspectRatio#
Root component.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
| Attribute | Description |
|---|---|
--ratio | 1 |