Aspect Ratio
basecn/aspect-ratioFreeComponent
Displays content within a desired ratio.
Live preview
live · rendered by the registry
Rendered by basecn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://basecn.dev/r/aspect-ratio.jsonSource
1import { cn } from "@/lib/utils";23interface AspectRatioProps extends React.ComponentProps<"div"> {4 ratio: number;5}67function AspectRatio({8 ratio,9 className,10 children,11 ...props12}: AspectRatioProps) {13 return (14 <div15 data-slot="aspect-ratio-wrapper"16 className="relative w-full"17 style={{ paddingBottom: `${(1 / ratio) * 100}%` }}18 >19 <div20 data-slot="aspect-ratio"21 className={cn("absolute inset-0", className)}22 {...props}23 >24 {children}25 </div>26 </div>27 );28}2930export { AspectRatio };
Files it writes
More from basecn
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | basecn | Components | Free | 2 deps | |
| Alertalert | basecn | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | basecn | Components | Free | 1 dep | |
| Autocompleteautocomplete | basecn | Components | Free | 2 deps | |
| Avataravatar | basecn | Components | Free | 1 dep | |
| Badgebadge | basecn | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | basecn | Components | Free | 2 deps | |
| Buttonbutton | basecn | Components | Free | 2 deps |
