Aspect Ratio
Displays content within a desired ratio.
import AspectRatio from '@dinui/react/aspect-ratio'
export default function AspectRatioVariantDemo() { return ( <AspectRatio ratio={16 / 9} className="overflow-hidden rounded-md"> <img src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" alt="Photo by Drew Beamer" /> </AspectRatio> )}Without JS
export default function AspectRatioTailwindOnlyDemo() { return ( <img src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" alt="Photo by Drew Beamer" className="aspect-video rounded-md" /> )}Installation
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
All done
You now can start using this component in your project.
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
Run the following command in your project
Terminal window npx @dinui/cli@latest add aspect-ratioTerminal window yarn dlx @dinui/cli@latest add aspect-ratioTerminal window pnpm dlx @dinui/cli@latest add aspect-ratioTerminal window bunx @dinui/cli@latest add aspect-ratio -
Update the import paths to match your project setup
-
All done
You now can start using this component in your project.
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
Install dependencies
Terminal window npm install @radix-ui/react-aspect-ratioTerminal window yarn add @radix-ui/react-aspect-ratioTerminal window pnpm add @radix-ui/react-aspect-ratioTerminal window bun add @radix-ui/react-aspect-ratio -
Copy and paste the following code into your project
'use client'import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio'const AspectRatio = AspectRatioPrimitive.Rootexport default AspectRatioexport { AspectRatioPrimitive } -
Update the import paths to match your project setup
-
All done
You now can start using this component in your project.