Dev Helpers
← Back

Expandable photo caption

Import and render <ExpandablePhotoCaption /> in a React project. Provide public/studio.jpg or pass your own image source.

Open this example in the interactive library

Live preview

Source code

// components/ExpandablePhotoCaption.tsx

export default function ExpandablePhotoCaption({
  src = "/studio.jpg",
  caption = "Inside the studio",
}: { src?: string; caption?: string } = {}) {
  return (
    <figure>
      <img src={src} alt={caption} style={{ width: "100%" }} />
      <details>
        <summary>Image description</summary>
        {caption}
      </details>
    </figure>
  );
}