Aspect Ratio
Displays content within a fixed aspect ratio container.
aspect-ratio-01

import { AspectRatio } from "@/components/ui/aspect-ratio";
export function AspectRatioDemo() {
return (
<AspectRatio ratio={16 / 9} className="w-full max-w-sm rounded-lg bg-muted">
<img
src="/img/hero-1.jpg"
alt="Designali showcase visual"
className="absolute inset-0 h-full w-full rounded-lg object-cover"
/>
</AspectRatio>
);
}aspect-ratio-02
import { AspectRatio } from "@/components/ui/aspect-ratio";
export function AspectRatioSquare() {
return (
<AspectRatio
ratio={1 / 1}
className="w-full max-w-[12rem] rounded-lg bg-muted"
>
<img
src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80"
alt="Designali UI preview"
className="absolute inset-0 h-full w-full rounded-lg object-cover"
/>
</AspectRatio>
);
}aspect-ratio-03
import { AspectRatio } from "@/components/ui/aspect-ratio";
export function AspectRatioPortrait() {
return (
<AspectRatio
ratio={9 / 16}
className="w-full max-w-[10rem] rounded-lg bg-muted"
>
<img
src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80"
alt="Designali portrait preview"
className="absolute inset-0 h-full w-full rounded-lg object-cover"
/>
</AspectRatio>
);
}aspect-ratio-04
Loading...
"use client";
import * as React from "react";
import { AspectRatio } from "@/components/ui/aspect-ratio";
export function AspectRatioVideo() {
return (
<figure className="w-full max-w-sm">
<AspectRatio ratio={16 / 9} className="rounded-lg bg-muted">
<video
src="/vid/colorful-spheres.mp4"
autoPlay
loop
muted
playsInline
className="h-full w-full rounded-lg object-cover"
/>
</AspectRatio>
<figcaption className="mt-2 text-center text-sm text-muted-foreground">
Designali motion components showcase
</figcaption>
</figure>
);
}Categories
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button
- Calendar
- Card
- Carousel
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Dialog
- Drawer
- Dropdown Menu
- Field
- Hover Card
- Input
- Input OTP
- Label
- Menubar
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip