Adventureland Registry

Lazy Load Image (next/image)

A next/image wrapper that tracks idle/loading/loaded/error state, shows a spinner placeholder and fades the image in once it loads.

AutoPlayTabsLazyLoadImage wraps next/image (with fill) and manages load state for you: it shows a spinner while loading, an error message on failure, and fades the image in when ready. It accepts an aspectRatioClass so it can sit inside fixed-ratio containers (carousels, tab panels, cards). Pass an empty src to defer loading until the slide is in view.

Installation

npx shadcn@latest add @adv/auto-play-tabs-lazy-load-image

Usage

import { AutoPlayTabsLazyLoadImage } from '@/components/autoPlayTabs/AutoPlayTabsLazyLoadImage';

<AutoPlayTabsLazyLoadImage
  src="/cover.jpg"
  alt="Cover"
  aspectRatioClass="aspect-video"
  priority
/>

Example

Demo cover

Props

PropTypeDefaultDescription
srcstringImage source; pass "" to defer loading.
altstringAlt text.
prioritybooleanfalseForwarded to next/image for above-the-fold images.
aspectRatioClassstring"aspect-4/3"Tailwind aspect-ratio class on the container.
spinnerSizestring"w-10 h-10"Size classes for the loading spinner.
containerClassNamestring""Extra classes on the wrapper.
imageClassNamestring""Extra classes on the image.
initialStatus"idle" | "loading" | "loaded" | "error""idle"Seed the load state (e.g. for cached images).
onLoadStatusChange(status) => voidNotified when the load state changes.

On this page