Dev Helpers
← Back

Responsive Next image

Place this file at components/ResponsiveNextImage.tsx in an App Router project. Provide public/studio.jpg or pass your own image source.

Open this example in the interactive library

Source code

// components/ResponsiveNextImage.tsx

import Image from "next/image";

export default function ResponsiveNextImage({
  src = "/studio.jpg",
  alt = "Inside the studio",
}: { src?: string; alt?: string } = {}) {
  return (
    <Image
      src={src}
      alt={alt}
      width={1200}
      height={800}
      sizes="(max-width: 700px) 100vw, 700px"
      style={{ width: "100%", height: "auto" }}
    />
  );
}