LQIP Image

Image component with Low Quality Image Placeholder (LQIP). Shows a blurred placeholder that fades into the full image on load.

Component

Remote URL mode (auto 2x2 placeholder)

Static import mode (full + placeholder)

Installation

pnpm dlx shadcn@latest add "https://pulkitxm.com/components/lqip-image.json"

Usage

Import the component

Add the LqipImage import to your file.

import { LqipImage } from "@/components/lqip-image";

Remote URL

Use with a remote URL. The component auto-generates the blur placeholder.

<LqipImage
  src="https://example.com/image.jpg"
  alt="Description"
  width={800}
  height={400}
/>;

Static import

For static imports, provide both full and placeholder images.

<LqipImage
  src={fullImage}
  placeholderSrc={placeholderImage}
  alt="Description"
  width={800}
  height={400}
/>;

Guidelines

  • For remote URLs, the component fetches the same image at 2x2 pixels for the placeholder; no extra asset needed.
  • For static imports, provide a small pre-generated placeholder (e.g. 20x20) as placeholderSrc for best results.
  • Use priority for above-the-fold images to load eagerly.
  • The container needs explicit dimensions when using fill; use a wrapper with aspect-ratio or fixed height.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
srcrequiredstring | StaticImageDataImage source. String URL for remote; StaticImageData for static import.
placeholderSrcStaticImageDataundefinedPlaceholder image for static import mode. Required when src is StaticImageData.
altrequiredstringAccessible alt text for the image.
widthnumberundefinedImage width in pixels. Omit when using fill.
heightnumberundefinedImage height in pixels. Omit when using fill.
classNamestringundefinedAdditional CSS classes for the image element.
containerClassNamestringundefinedAdditional CSS classes for the container.
sizesstringundefinedResponsive sizes attribute for next/image.
prioritybooleanfalseLoad image eagerly (for above-the-fold images).
fillbooleanfalseFill the container. Requires parent with explicit dimensions.
qualitynumberundefinedImage quality (1-100). Passed to next/image.

Examples

Remote URL

Remote URL mode. Auto-generates a tiny 2x2 placeholder from the same URL.

Remote URL mode (auto 2x2 placeholder)

Static import mode (full + placeholder)

import { LqipImage } from "@/components/lqip-image";

export function LqipImageBasic() {
  return (
    <LqipImage
      src="https://example.com/image.jpg"
      alt="Description"
      width={800}
      height={400}
    />
  );
}

Static import

Static import mode. Provide both full and placeholder images.

Remote URL mode (auto 2x2 placeholder)

Static import mode (full + placeholder)

import { LqipImage } from "@/components/lqip-image";
import fullImage from "@/assets/full.webp";
import placeholderImage from "@/assets/placeholder.webp";

export function LqipImageStatic() {
  return (
    <LqipImage
      src={fullImage}
      placeholderSrc={placeholderImage}
      alt="Description"
      width={800}
      height={400}
    />
  );
}

Fill container

Use fill to make the image fill its container.

Remote URL mode (auto 2x2 placeholder)

Static import mode (full + placeholder)

import { LqipImage } from "@/components/lqip-image";

export function LqipImageFill() {
  return (
    <div className="relative h-64 w-full">
      <LqipImage
        src="https://example.com/image.jpg"
        alt="Description"
        fill
      />
    </div>
  );
}

Last updated on Mar 13

Made with ❤️ by Pulkit & Cursor :)

© 2026 Pulkit. All rights reserved

DMCA Verified

Last updated: