Back to Shark UI

Aspect Ratio

docs/components/aspect-ratio

latest5.7 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Aspect Ratio

Copy Markdown

Wrapper that maintains aspect ratio for content.

PreviewCode

1:1

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/aspect-ratio

Usage#

import { AspectRatio } from "@/components/ui/aspect-ratio";
<AspectRatio>
  
</AspectRatio>

Examples#

Square#

PreviewCode

1:1

Portrait#

PreviewCode

9:16

Video#

PreviewCode

16:9

Responsive#

Use [--ratio:*] with breakpoints to change the ratio at different screen sizes.

PreviewCode

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.

PropTypeDefault
classNamestring-
asChildbooleanfalse
AttributeDescription
--ratio1

[

Previous page

Announcement ](/docs/components/announcement)[

Next page

Autocomplete ](/docs/components/autocomplete)

On This Page

InstallationUsageExamplesSquarePortraitVideoResponsiveAPI ReferenceAspectRatio