Aspect Ratio
adn-ui/aspect-ratioFreeComponent
Displays content within a desired aspect ratio.
Live preview
live · rendered by the registry
Rendered by adn-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.awaiden.com/r/aspect-ratio.jsonSource
1"use client";23import "./aspect-ratio.css";4import type React from "react";5import { cn } from "tailwind-variants";67import { AspectRatioContext } from "./aspect-ratio.context";8import { aspectRatioVariants, type AspectRatioVariants } from "./aspect-ratio.variants";910export type AspectRatioProps = {11 /**12 * The desired aspect ratio (width / height).13 * @default 16 / 914 */15 ratio?: number;16} & AspectRatioVariants & React.ComponentProps<"div">;1718export const AspectRatioRoot = ({19 children,20 className,21 ratio = 16 / 9,22 style,23 ...props24}: AspectRatioProps) => {25 const slots = aspectRatioVariants();2627 return (28 <AspectRatioContext.Provider value={{ slots }}>29 <div30 className={cn(slots.root(), className)}31 style={{ aspectRatio: `${ratio}`, ...style }}32 {...props}33 >34 {children}35 </div>36 </AspectRatioContext.Provider>37 );38};3940export const AspectRatio = AspectRatioRoot;
What it pulls in
npm packages
Files it writes
More from adn-ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | adn-ui | Components | Free | 2 deps · 5 files | |
| Alert Dialogalert-dialog | adn-ui | Components | Free | 2 deps · 5 files | |
| Autocompleteautocomplete | adn-ui | Components | Free | 2 deps · 5 files | |
| Avataravatar | adn-ui | Components | Free | 2 deps · 5 files | |
| Badgebadge | adn-ui | Components | Free | 1 dep · 5 files | |
| Breadcrumbbreadcrumb | adn-ui | Components | Free | 1 dep · 5 files | |
| Buttonbutton | adn-ui | Components | Free | 1 dep · 4 files | |
| Button Groupbutton-group | adn-ui | Components | Free | 1 dep · 5 files |
