Installation
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
uvx django_shadcn@latest add aspect_ratio
Usage
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
<c-aspect-ratio ratio='16/9' class='overflow-hidden rounded-lg'>
<img src='/cover.jpg' alt='' class='size-full object-cover' />
</c-aspect-ratio>
Radix reserves the space with a padding hack. Here it is the native aspect-
ratio CSS property, so ratio takes anything the property accepts: 16/9,
4/3, 1.85. The default is 1/1.
Examples
Square
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
<c-aspect-ratio class='overflow-hidden rounded-lg bg-muted'>...</c-aspect-ratio>
Portrait
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
<c-aspect-ratio ratio='3/4' class='overflow-hidden rounded-lg bg-muted'>...</c-aspect-ratio>