DocumentationSkins and captions

Skins and captions

Pick a skin (card, plain, caption, overlay, hover or image), choose hover effects and fill items with titles, categories, prices, authors, badges and durations.

A skin is the visual style of an item: what the card looks like and where the caption sits. Set it with the skin option or attribute. The default is card.

html
<media-boxes skin="overlay" columns="3"> ... </media-boxes>

The six skins #

SkinLook
cardA surface with a radius, a hairline border and a soft shadow that lifts on hover. The image sits on top and the content is padded below.
plainOnly the image has a radius. The content sits below with no background or border.
captionLike plain, but the content is centred and set a little smaller.
overlayThe content sits on the bottom of the image over a gradient, always visible, in white text.
hoverThe content is centred over the image and shown by the hover overlay effect. On touch devices (hover: none) the caption is always visible, so nothing is hidden from people who cannot hover.
imageOnly the image is drawn. The content stays in the page, hidden, so its title and text still feed the lightbox and the image's accessible name.

In the overlay and hover skins the content is placed over the image, so it adds no height to the item. In the justified and mosaic layouts the content is always over the image, and plain, card and caption then behave like hover.

Hover effects #

Two options control what happens when someone points at an item or focuses it with the keyboard. They live in hover:

js
grid.options = { skin: 'hover', hover: { overlay: 'slide-up', image: 'zoom' } };
html
<media-boxes skin="hover" hover-overlay="slide-up" hover-image="zoom"> ... </media-boxes>
OptionValuesDefault
hover.overlay'none', 'fade', 'slide-up', 'slide-down', 'slide-left', 'slide-right', 'reveal', 'zoom', 'blur', 'direction''fade'
hover.image'none', 'zoom', 'zoom-out', 'grayscale', 'color', 'blur', 'tilt''zoom'

direction makes the overlay enter from the side the pointer came from, and tilt gives a soft 3D tilt that follows a mouse. Tilt is skipped on touch screens and when the visitor prefers reduced motion. Play with every combination in the hover effects playground.

Entry animation #

enter is how items appear when they are first shown, filtered back in, or loaded.

ValueEffect
'fade-up' (default)Fade in while moving up a little.
'fade'Fade in.
'scale'Grow from slightly smaller.
'flip'A short flip.
'none'Appear at once.

stagger (milliseconds, default 40) is the delay between items that enter together, capped at 12 steps. duration (default 450) is the length of layout and filter moves. With prefers-reduced-motion: reduce there is no stagger and no movement.

What goes in an item #

In HTML an item is made of these parts, all optional apart from the item itself:

html
<article class="mb-item" data-id="p1" data-category="Nature, Outside" data-date="2026-04-05" data-duration="4:12">
  <a class="mb-media" href="images/big.jpg" data-mb-caption="A longer caption for the lightbox">
    <img src="images/small.jpg" width="720" height="480" alt="A white stair">
    <span class="mb-badge">New</span>
  </a>
  <div class="mb-content">
    <p class="mb-cats"><span>Nature</span><span>Outside</span></p>
    <h3 class="mb-title">White stair</h3>
    <p class="mb-text">A single flight cut into a pale wall.</p>
    <p class="mb-meta">
      <time class="mb-date" datetime="2026-04-05">Apr 5, 2026</time>
      <span class="mb-author">Lena Ito</span>
      <span class="mb-price">$29</span>
    </p>
  </div>
</article>

Everything inside .mb-content is styled by the skin, so you write plain semantic HTML and the skin does the rest.

Item data fields #

When you build items from JSON (items in the options, or grid.addItems([...])), each item is a plain object. The engine writes the same markup as above, using textContent only, so titles and text are never parsed as HTML.

FieldTypeWhat it does
idstringBecomes data-id. Used by deep links, openLightbox(id) and removeItems(id).
titlestringThe item title (.mb-title). Also the lightbox title and the image's accessible name.
textstringA short description (.mb-text). Also the default lightbox caption.
datestringAn ISO date such as '2026-04-05'. Shown in .mb-meta and usable for sorting by date.
termsobjectCategory terms per filter group, for example { category: ['Nature'], tone: ['Light'] }.
dataobjectExtra data-* attributes, for example { likes: 754 }. Numbers can be sorted and searched. They are not displayed.
thumbobjectThe grid image: src, width, height, srcset, sizes, alt. Give width and height so the layout is stable before the image loads.
mediaobjectWhat the lightbox opens: type, src, width, height, caption, poster, srcset, sizes. Leave it out for an item without a lightbox. See Lightbox.
linkobject{ href, target }. Makes the title a link. Only web, mail, tel and relative URLs are used; any other scheme (such as javascript:) leaves the title as plain text.
spanobject{ cols, rows } for mosaic and, for cols, masonry.
pricestring or numberShown in .mb-meta. A number is formatted with the item currency. Any other string is shown as written.
authorstringShown in .mb-meta.
metaarrayExtra entries for .mb-meta: strings, or objects { text, class, href, datetime }. An href with an unsafe scheme such as javascript: is dropped.
badgestringA small label on the image (.mb-badge), for example 'New' or 'Sold out'.
overlayobject{ label, icon }. A custom overlay with a text label and an icon from the list below.
durationstringFor video items, for example '4:12'. Shown as a chip on the image.

The order inside .mb-meta is date, author, price and then the meta entries. Dates are formatted with the browser language.

js
grid.addItems([{
  id: 'stool',
  title: 'Oak stool',
  text: 'Turned from one piece of oak.',
  date: '2026-03-12',
  terms: { category: ['Furniture'] },
  price: 129,
  author: 'Ostra Goods',
  badge: 'New',
  meta: ['In stock', { text: 'Details', href: '/shop/oak-stool' }],
  overlay: { label: 'Quick view', icon: 'expand' },
  thumb: { src: 'images/stool-600.jpg', width: 600, height: 600, alt: 'An oak stool' },
  media: { type: 'image', src: 'images/stool-1600.jpg', width: 1600, height: 1600 },
}]);

Icons you can name in overlay.icon (and in custom lightbox buttons): close, arrow-left, arrow-right, expand, play, pause, zoom-in, zoom-out, fullscreen, fullscreen-exit, download, share, grid, search, sort-asc, sort-desc, link, check.

Terms on the card #

Terms (categories) are shown in .mb-cats. For items built from data, showTerms chooses what is printed:

ValueResult
'first' (default)The terms of the first group that has any.
'all'Every group, on one line. A group boundary is marked for CSS to draw a separator.
'category' (any group name)Only that group.
falseNo terms on the card. Filtering still works.

The separators are CSS. Change them with --mb-cats-sep (between terms, default a middle dot) and --mb-cats-group-sep (between groups, default a slash). See Theming. If you write the markup yourself, you decide what goes into .mb-cats.

Price formatting #

A numeric price is formatted with Intl.NumberFormat, using three options:

OptionDefaultMeaning
currency'USD'An ISO 4217 code such as 'EUR'.
localenot setA BCP 47 tag such as 'de-DE'. Without it the browser language is used.
priceDecimals'auto''auto' drops the decimals of whole amounts ($24, but $24.50). A number from 0 to 6 forces exactly that many.
js
grid.options = { currency: 'EUR', locale: 'fr-FR', priceDecimals: 2 };

A string such as 'From $20' is shown as written. These options apply to items you add from data, not to markup you write yourself.

Video badge #

An item whose media is video, youtube or vimeo shows a play icon in the middle of the image. If the item has data-duration (or duration in JSON), for example "4:12", a small chip with the length appears in the top corner. videoBadge: false turns both off. See the video example site.

Video that plays in the grid #

By default a video item opens in the lightbox. With videoPlay: 'inline' (or data-mb-play="inline" on one item, play: 'inline' in JSON) the click starts the video in place: the thumbnail is covered by the player, at exactly the same size, so the layout does not move.

html
<article class="mb-item" data-mb-play="inline">
  <a class="mb-media" href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">...</a>
</article>

The image ratio comes from the width and height of the <img>. If they are missing, the engine measures the image after it loads, and the layout adjusts then. Always give both to avoid a jump. When an item's link is not an image, set data-mb-type as described in Lightbox. An item with data-mb-type="link" simply follows its link.