JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css"
/>
</head>
<body>
<div>
<p>
<a
data-fancybox="gallery"
data-src="https://lipsum.app/id/2/1024x768"
data-caption="Optional caption,<br />that can contain <em>HTML</em> code"
>
<img src="https://lipsum.app/id/2/200x150" />
</a>
<a data-fancybox="gallery" data-src="https://lipsum.app/id/3/1024x768">
<img src="https://lipsum.app/id/3/200x150" />
</a>
<a data-fancybox="gallery" data-src="https://lipsum.app/id/4/1024x768">
<img src="https://lipsum.app/id/4/200x150" />
</a>
</p>
<div id="dialog-content" style="display:none;max-width:500px;">
<h2>Hello, world!</h2>
<p>
<input type="text" value="" />
</p>
<p>
Try hitting the tab key and notice how the focus stays within the dialog
itself.
</p>
<p>
To close dialog hit the esc button, click on the overlay or just click the
close button.
</p>
<p>
Element used to launch the modal would receive focus back after closing.
</p>
</div>
<p>
<button data-fancybox data-src="#dialog-content">Launch Dialog</button>
</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script>
<script>
// Enable Fancybox for any element with the `data-fancybox` attribute
Fancybox.bind('[data-fancybox]', {
// Your custom options
});
// Set custom options for elements with the `data-fancybox="gallery"` attribute
Fancybox.bind('[data-fancybox="gallery"]', {
//...