Skip to content

    Browse components

    Aspect Ratio

    Box locked to a width/height ratio, with a shimmer placeholder that dissolves into the image once it loads.

    Open
    Customize

    Installation

    npx shadcn@latest add @glint-ui/aspect-ratio

    First time using @glint-ui? Add the registry to components.json once, or install by URL: npx shadcn@latest add https://glintui.vercel.app/r/aspect-ratio.json

    Usage

    import { AspectRatio } from "@/components/ui/aspect-ratio";
    
    <AspectRatio ratio={16 / 9} src="/cover.jpg" alt="Mountain lake at dawn" className="rounded-xl" />

    Props

    PropTypeDefaultDescription
    rationumber1.7777777777777777Width divided by height, e.g. 16 / 9.
    shimmerbooleantrueAnimated placeholder until the image loads.
    srcstring—Image rendered with object-cover. Omit to place your own children.
    altstring""Alt text for the image.
    childrenReactNode—Any content (video, iframe, map) to fit inside the box.
    classNamestring—Extra classes for the root element.