Fancybox

fancybox — lightbox link wrapper

Thin wrapper around @fancyapps/ui (v5+). Renders a thumbnail link with hover overlay + magnifier icon; clicking opens the full image in a lightbox. Auto-binds via data-fancybox attribute, no manual init.

Install

npm install @fancyapps/ui
npx czg-ui add fancybox
// resources/sass/app.scss
@import '@fancyapps/ui/dist/fancybox/fancybox.css';
@import 'components/fancybox';
// resources/js/app.js
import './components/fancybox';

Requires base. Pulls @fancyapps/ui as npm dependency.

Parameters

ParamTypeDefaultNotes
srcstringURL of the full-size image (required)
thumbstring\null=srcThumbnail URL (defaults to full image)
altstring''Image alt text
groupstring\null'fancybox'Gallery id — items sharing it are navigable in the lightbox
captionstring\nullCaption shown in the lightbox
classstring\nullExtra class on the <a>
showOverlaybooltrueHover overlay with magnifier icon

Usage — single image

{include /app/components/Gallery/fancybox.latte,
    src   => '/img/photo-large.jpg',
    thumb => '/img/photo-thumb.jpg',
    alt   => 'Realizace 2025'}

All items sharing group become a single carousel inside the lightbox (arrow keys, swipe on mobile):

{foreach $photos as $p}
    {include /app/components/Gallery/fancybox.latte,
        src     => $p->fullUrl,
        thumb   => $p->thumbUrl,
        group   => 'gallery-realizace',
        caption => $p->title}
{/foreach}

When NOT to use

  • Hero images / decorative photos that the user is not expected to

zoom into — adds JS weight for nothing

  • PDFs, videos, iframes — Fancybox supports them, but consider a

dedicated viewer (PDF.js, plyr) with better UX

  • Touch-only mobile with a single image — native pinch-zoom may be

enough

Live preview

ui.czechgroup.cz/component/fancybox

Další kategorie