Skip to content
v0.9.1
Components

Gallery & lightbox

A grid of thumbnails, each a link to the big picture. Click one and it opens large in a lightbox, with arrows, a counter and a caption; arrow keys and swipes move through them. You can zoom in, pull the picture down to close it on a phone, show a strip of thumbnails and mix in videos. Without JavaScript the links just open the pictures.

Gallery

<div class="gallery">
  <a class="gallery-item" href="../examples/img/sample-1.svg"><img src="../examples/img/sample-1.svg" alt="Yellow hills at noon" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-2.svg"><img src="../examples/img/sample-2.svg" alt="Violet dusk over the hills" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-3.svg"><img src="../examples/img/sample-3.svg" alt="A green valley" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-4.svg"><img src="../examples/img/sample-4.svg" alt="Pink sunrise over the sea" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-5.svg"><img src="../examples/img/sample-5.svg" alt="A blue lake between mountains" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-6.svg"><img src="../examples/img/sample-6.svg" alt="An orange desert" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-7.svg"><img src="../examples/img/sample-7.svg" alt="Night hills under the moon" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-8.svg"><img src="../examples/img/sample-8.svg" alt="A small town at dusk" loading="lazy"></a>
</div>

Each link points at the large picture; the <img> inside can be a smaller copy. The caption in the lightbox comes from data-caption on the link, else a .gallery-caption inside it, else the picture's alt.

A big first picture, with captions

.gallery-feature makes the first one twice as big; --gallery-ratio changes the shape (square by default).

<div class="gallery gallery-feature" style="--gallery-ratio: 4 / 3">
  <a class="gallery-item" href="../examples/img/sample-8.svg" data-caption="The town square, an hour before the lights came on."><img src="../examples/img/sample-8.svg" alt="A small town at dusk"><span class="gallery-caption">The town</span></a>
  <a class="gallery-item" href="../examples/img/sample-5.svg"><img src="../examples/img/sample-5.svg" alt="A blue lake between mountains"><span class="gallery-caption">The lake</span></a>
  <a class="gallery-item" href="../examples/img/sample-6.svg"><img src="../examples/img/sample-6.svg" alt="An orange desert"><span class="gallery-caption">The desert</span></a>
  <a class="gallery-item" href="../examples/img/sample-2.svg"><img src="../examples/img/sample-2.svg" alt="Violet dusk over the hills"><span class="gallery-caption">Dusk</span></a>
  <a class="gallery-item" href="../examples/img/sample-7.svg"><img src="../examples/img/sample-7.svg" alt="Night hills under the moon"><span class="gallery-caption">Night</span></a>
</div>

Columns

.gallery-columns keeps each picture's own shape and flows them into columns, for photos of mixed sizes.

<div class="gallery gallery-columns">
  <a class="gallery-item" href="../examples/img/sample-3.svg"><img src="../examples/img/sample-3.svg" alt="A green valley" width="1200" height="800"></a>
  <a class="gallery-item" href="../examples/img/sample-clip-poster.png"><img src="../examples/img/sample-clip-poster.png" alt="Sun rising over yellow hills" width="960" height="540"></a>
  <a class="gallery-item" href="../examples/img/sample-4.svg"><img src="../examples/img/sample-4.svg" alt="Pink sunrise over the sea" width="1200" height="800"></a>
  <a class="gallery-item" href="../examples/img/sample-1.svg"><img src="../examples/img/sample-1.svg" alt="Yellow hills at noon" width="1200" height="800"></a>
  <a class="gallery-item" href="../examples/img/sample-7.svg"><img src="../examples/img/sample-7.svg" alt="Night hills under the moon" width="1200" height="800"></a>
</div>

Zoom

Every lightbox zooms, with nothing to set up. Open any picture on this page and try it:

The picture goes up to four times its size and never slides off the screen. Moving to another picture starts it whole again.

Pull down to close

On a touch screen, drag the picture down: it follows your finger, the dark fades, and letting go far enough closes the lightbox. Let go early and it springs back. A sideways swipe still moves to the next picture.

Thumbnails

Add data-lightbox-thumbs to the gallery and the lightbox shows a strip of small pictures along the bottom. The one on screen is marked, and a click jumps straight to any other.

<div class="gallery" id="g-thumbs" data-lightbox-thumbs style="--gallery-ratio: 4 / 3">
  <a class="gallery-item" href="../examples/img/sample-1.svg" data-caption="Day 1: the hills above the village, just after noon."><img src="../examples/img/sample-1.svg" alt="Yellow hills at noon" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-3.svg" data-caption="Day 2: down into the valley."><img src="../examples/img/sample-3.svg" alt="A green valley" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-5.svg" data-caption="Day 3: the lake, cold enough to count as brave."><img src="../examples/img/sample-5.svg" alt="A blue lake between mountains" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-6.svg" data-caption="Day 4: the desert road."><img src="../examples/img/sample-6.svg" alt="An orange desert" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-4.svg" data-caption="Day 5: sunrise from the ferry."><img src="../examples/img/sample-4.svg" alt="Pink sunrise over the sea" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-7.svg" data-caption="Day 6: the last night out."><img src="../examples/img/sample-7.svg" alt="Night hills under the moon" loading="lazy"></a>
</div>
<div class="gallery" data-lightbox-thumbs>
  <a class="gallery-item" href="big-1.jpg"><img src="small-1.jpg" alt="Yellow hills at noon"></a>
  <a class="gallery-item" href="big-2.jpg"><img src="small-2.jpg" alt="A green valley"></a>
</div>

Videos

A link to a video file (.mp4, .webm) plays in the lightbox, with the thumbnail as its poster. The thumbnail gets a play mark by itself. For YouTube or Vimeo, keep the link pointing at the video's page and put the embed address in data-video.

<div class="gallery" id="g-video" data-lightbox-thumbs style="--gallery-ratio: 16 / 9">
  <a class="gallery-item" href="../examples/img/sample-clip.webm" data-caption="Sunrise over the hills, 6 seconds."><img src="../examples/img/sample-clip-poster.png" alt="Sun rising over yellow hills" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-2.svg"><img src="../examples/img/sample-2.svg" alt="Violet dusk over the hills" loading="lazy"></a>
  <a class="gallery-item" href="../examples/img/sample-8.svg"><img src="../examples/img/sample-8.svg" alt="A small town at dusk" loading="lazy"></a>
</div>
<!-- a video file -->
<a class="gallery-item" href="clip.mp4"><img src="poster.jpg" alt="Sun rising over yellow hills"></a>

<!-- YouTube: the link still works without JavaScript -->
<a class="gallery-item" href="https://www.youtube.com/watch?v=VIDEO_ID"
   data-video="https://www.youtube-nocookie.com/embed/VIDEO_ID"><img src="poster.jpg" alt="How Momo works"></a>

From a script

Momo.lightbox.open('#photos', 2);   // open a group at its third picture
Momo.lightbox.zoom(2);              // 1 = the whole picture, up to 4
Momo.lightbox.close();

Classes and options

Class / attributeDoes
.galleryThe grid: as many as fit, each at least 176px (--gallery-min), --gallery-gap 12px
a.gallery-itemA thumbnail link (square by default: --gallery-ratio); zooms a touch on hover
.gallery-captionA small caption over the bottom of a thumbnail
.gallery-feature / .gallery-columnsBig first picture / natural shapes in columns
data-captionThe caption shown in the lightbox
data-lightbox-thumbsOn the group: a strip of thumbnails in the lightbox
data-videoOn a link: the embed address to play (a link to an .mp4 or .webm needs nothing)
data-momo-lightboxTurns any group of picture links into a lightbox set (not only .gallery); ="false" turns it off

Accessibility

Start

OverviewStart Getting startedStart CustomizeStart

Guides

AccessibilityGuides BreakpointsGuides ChangelogGuides Customize componentsGuides JavaScriptGuides MotionGuides OptimizeGuides PhonesGuides RebootGuides Right-to-left (RTL)Guides Stacking orderGuides Using Momo with AIGuides

Foundations

ColorsFoundations TypographyFoundations ProseFoundations Images & figuresFoundations CodeFoundations Lines & shadowsFoundations Dark modeFoundations

Forms

Checkbox & switchForms ComboboxForms Date pickerForms Date rangeForms Fields & labelsForms File uploadForms Floating labelsForms Number stepperForms PasswordForms PIN codeForms RatingForms SelectForms SliderForms Tag inputForms Time pickerForms ValidationForms

Components

AccordionComponents Alert & bannerComponents AvatarComponents BadgeComponents BreadcrumbComponents ButtonComponents Button groupComponents CalendarComponents CardComponents CarouselComponents ChartsComponents ChipsComponents CollapseComponents Command paletteComponents CommentsComponents Confirm dialogsComponents Cookie bannerComponents Data tableComponents Description listComponents Dialog & toastComponents DividerComponents DrawerComponents Dropdown menuComponents Empty stateComponents File managerComponents Filter & sortComponents Gallery & lightboxComponents Inbox & chatComponents Infinite scrollComponents KanbanComponents Keyboard shortcutsComponents List groupComponents MarqueeComponents Media objectComponents Nav overflowComponents Notification centerComponents PaginationComponents ProgressComponents Pull to refreshComponents SkeletonComponents SortableComponents SpinnerComponents Split viewComponents Stat cardComponents Steps & wizardComponents Swipe actionsComponents TableComponents TabsComponents TimelineComponents TogglerComponents Tooltip & popoverComponents TourComponents Tree viewComponents VideoComponents WhiteboardComponents

Layout

Announcement barLayout App shellLayout Back to topLayout Container & sectionLayout ExamplesLayout FooterLayout HeroLayout JumbotronLayout Mega menuLayout NavbarLayout Site sidebarLayout

Sections

Bento gridSections Blog cardsSections Call to actionSections Contact & newsletterSections FAQSections FeaturesSections Logo cloudSections PricingSections TeamSections TestimonialsSections

Utilities

OverviewUtilities State variantsUtilities Display & flexUtilities Grid & gapUtilities SpacingUtilities SizingUtilities TextUtilities Links & color strengthUtilities Position & overflowUtilities BackgroundsUtilities Borders & effectsUtilities Transforms & filtersUtilities InteractionsUtilities

Helpers

Fixed, sticky & frostedHelpers Hover & focusHelpers Hover revealHelpers Icon linkHelpers PrintHelpers Relative timeHelpers Screen reader textHelpers Scroll inHelpers ScrollspyHelpers Share buttonHelpers Skip linkHelpers StacksHelpers Stretched linkHelpers Theme toggleHelpers Truncated textHelpers

Page patterns

404 pagePage patterns Coming soonPage patterns Login & registerPage patterns SettingsPage patterns ProfilePage patterns CRM contactsPage patterns ProjectsPage patterns File manager pagePage patterns Billing & plansPage patterns Help centerPage patterns Mobile app screensPage patterns
↑ ↓ moveEnter openEsc close