HextaUI

Aspect ratio: Without placeholder

placeholder={false} turns off the loading shimmer, the fade-in and the fallback, for the plain shadcn behavior.

Sunset over mountains
import { AspectRatio } from "@/components/ui/aspect-ratio"

export function AspectRatioWithoutPlaceholder() {
  return (
    <div className="w-full max-w-md">
      <AspectRatio ratio={16 / 9} placeholder={false} className="rounded-lg">
        <img src="/preview/landscape.svg" alt="Sunset over mountains" />
      </AspectRatio>
    </div>
  )
}

This adds the example as components/examples/aspect-ratio/without-placeholder.tsx, together with the Aspect ratio component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/aspect-ratio-without-placeholder.json

To add only the component, follow the Aspect ratio installation.

Props in this example

The Aspect ratio props this example sets, from the API reference.

PropTypeDefault
ratio
number | `${number}/${number}` | `${number}:${number}`1
placeholderShows a shimmer while the media loads and a fallback when it fails.
booleantrue

Every prop is in the Aspect ratio API reference.

See them all, with keyboard support and accessibility notes, on the Aspect ratio page.