react-grid-gallery icon indicating copy to clipboard operation
react-grid-gallery copied to clipboard

Can I add a link in the caption?

Open jefflung opened this issue 2 years ago • 0 comments

Hi, can I add a link in caption so I can redirect to a new web page by clicking the link? Thanks

jefflung avatar Jul 29 '21 09:07 jefflung

Hi @jefflung!

You can pass anything that React can render via caption prop, any jsx included.

const image1 = {
  src: "https://upload.wikimedia.org/wikipedia/commons/e/ee/Apples.jpg",
  thumbnail: "https://upload.wikimedia.org/wikipedia/commons/e/ee/Apples.jpg",
  thumbnailWidth: 320,
  thumbnailHeight: 480,
  caption: (
    <a
      href="https://en.wikipedia.org/wiki/Apple"
      target="_blank"
      rel="noreferrer"
    >
      Apple
    </a>
  )
};

function App() {
  return <Gallery images={[image1]} />;
}

Here is a sandbox to play with.

Sorry for the late response and have an awesome day!

itoldya avatar Aug 28 '22 11:08 itoldya