Dev Helpers
← Back

Fill image hero

Place this file at components/FillImageHero.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/FillImageHero.tsx

import Image from "next/image";

export default function FillImageHero({
  src = "/studio.jpg",
  alt = "Inside the studio",
}: { src?: string; alt?: string } = {}) {
  return (
    <section style={{ position: "relative", height: "clamp(16rem,45vw,35rem)" }}>
      <Image src={src} alt={alt} fill sizes="100vw" style={{ objectFit: "cover" }} />
    </section>
  );
}