DocumentationOptions reference

Options reference

Every Media Boxes option in one place, with type, default and meaning, grouped by layout, appearance, loading, filters, deep links, lightbox, items and text.

Every option, grouped by purpose. Defaults in this page are read from the engine source when the documentation is built, so they are always the real ones.

How options are resolved #

Options come from four places. A later place wins over an earlier one, and objects are merged key by key while arrays are replaced whole:

  1. The engine defaults.
  2. A <script type="application/json" data-mb-options> block inside the element.
  3. HTML attributes on the element (only the options listed in HTML attributes).
  4. el.options = { ... } assigned from JavaScript.

Assigning el.options at any time merges the object into the current options and re-renders the grid. Wrong values never throw: an unknown name for a layout, skin, entry animation or theme falls back to the default, and numbers are clamped into a valid range. Reading el.options returns the fully resolved options.

js
const grid = document.querySelector('media-boxes');
grid.options = { columns: 5, lightbox: { download: true } }; // merged, not replaced
console.log(grid.options.lightbox.loop);                      // true

Layout #

OptionTypeDefaultDescription
layout'grid' | 'masonry' | 'justified' | 'mosaic''masonry'How items are placed. See Layouts.
columnsinteger 1 or more, or 'auto'4Number of columns. With 'auto' the count follows the width and minColumnWidth. Ignored by justified.
minColumnWidthnumber (px)260Narrowest column when columns is 'auto'.
gapnumber, or [rowGap, columnGap]16Space between items in pixels.
aspectRationumber or 'W/H'4 / 3Cell shape for grid and mosaic (width divided by height). A bad value falls back to 4/3.
rowHeightnumber (px)240Target row height of justified.
lastRow'left' | 'justify' | 'hide''left'What justified does with an incomplete last row.
mosaicPattern'auto' | 'none''auto''auto' gives items without a span a repeating pattern of big and small cells.
breakpointsarray of { maxWidth, columns?, gap?, rowHeight?, aspectRatio?, minColumnWidth? }, or nullnullnull derives them from columns. An array, even [], is used exactly as given. They match the width of the element.

Appearance #

OptionTypeDefaultDescription
skin'card' | 'plain' | 'caption' | 'overlay' | 'hover' | 'image''card'The look of each item. See Skins and captions.
hover.overlaystring'fade''none', 'fade', 'slide-up', 'slide-down', 'slide-left', 'slide-right', 'reveal', 'zoom', 'blur' or 'direction'.
hover.imagestring'zoom''none', 'zoom', 'zoom-out', 'grayscale', 'color', 'blur' or 'tilt'.
enter'none' | 'fade' | 'fade-up' | 'scale' | 'flip''fade-up'Entry animation for items that appear.
staggernumber (ms)40Delay between items entering together, capped at 12 steps.
durationnumber (ms)450Length of layout and filter moves.
theme'light' | 'dark' | 'auto''light'Colour set. 'auto' follows the system. See Theming.

Loading #

OptionTypeDefaultDescription
load.mode'all' | 'button' | 'scroll' | 'pages''button'How the items are revealed. See Loading.
load.initialinteger, 1 or more12Items shown first, and the page size in pages mode.
load.stepinteger, 1 or more8Items added per load in button and scroll modes.

Filters, search and sort #

OptionTypeDefaultDescription
filtersarray of { group, label?, ui?, multiple?, all?, counts? } or group names[]Filter groups. ui is 'pills', 'tabs' or 'select'. See Filtering and search.
filterLogic'and' | 'or''and'How several groups combine. Inside one multiple group terms always combine with OR.
searchfalse, true, or { placeholder?, fields?, ui? }falseTurns search on. fields default to ['title', 'text']. ui: false keeps search active without the box.
sortfalse, or { options, default?, order? }falseA sort drop-down. options is a list of { key, label } (or strings), default the starting key and order is 'asc' or 'desc'.
OptionTypeDefaultDescription
deepLink.filterbooleantrueStore the filters and sort in the address.
deepLink.searchbooleanfalseStore the search text.
deepLink.lightboxbooleantrueStore the open slide, and open it when the page loads.

Deep links need an id on the element. deepLink: false switches all three off. See Filtering and search.

All of these live under lightbox. They are explained in Lightbox. lightbox: false turns the whole lightbox off.

OptionTypeDefaultDescription
lightbox.enabledbooleantrueOpen items in the lightbox.
lightbox.scope'filtered' | 'all''filtered'Which items the visitor can flip through.
lightbox.loopbooleantrueWrap around at the ends (more than two slides).
lightbox.counterbooleantrueShow the position counter.
lightbox.captionsbooleantrueShow title and caption.
lightbox.thumbnailsbooleantrueShow the thumbnail strip.
lightbox.zoombooleantrueAllow zooming.
lightbox.fullscreenbooleantrueShow the fullscreen button.
lightbox.downloadbooleanfalseShow the download button.
lightbox.sharebooleanfalseShow the share button.
lightbox.transition'slide' | 'fade''slide'Movement between slides.
lightbox.openAnimation'zoom' | 'fade''zoom'How the lightbox opens and closes.
lightbox.swipeToClosebooleantrueDrag down to close.
lightbox.motion'spring' | 'ease''spring'Physical spring motion or plain easing.
lightbox.toolbarnull, or { left?, right? }nullChoose and order the top bar buttons, or add custom ones.
lightbox.backdropClick'close' | false'close'What a tap on the empty stage does.
lightbox.idlefalse or number (ms)2500Hide the controls after inactivity during a slideshow or fullscreen.
lightbox.wheel'zoom' | 'slide' | 'close''zoom'What the mouse wheel does.
lightbox.keyboardtrue, false or { key: action }trueKeyboard shortcuts and remapping.
lightbox.itemGallery'inline' | 'isolated''inline'Several slides in one item: 'inline' keeps them in the overall sequence, 'isolated' flips only through the opened item's slides. See Lightbox.
lightbox.preloadinteger 0 to 51Slides loaded on each side of the current one.
lightbox.slideshow.enabledbooleantrueShow the slideshow button.
lightbox.slideshow.autoStartbooleanfalsePlay as soon as it opens.
lightbox.slideshow.intervalnumber (ms)4000Time per slide.
lightbox.slideshow.pauseOnHoverbooleanfalsePause while the mouse is over the stage.

Items and formatting #

OptionTypeDefaultDescription
itemsarray of item objectsnoneItems to create from data, added after any items written in HTML. Not part of the defaults. See Skins and captions.
showTerms'first' | 'all' | false | '<group>''first'Which terms are printed on cards built from data.
priceDecimals'auto' or integer 0 to 6'auto'Decimals of a numeric price.
currencyISO 4217 code'USD'Currency of a numeric price. Invalid codes fall back to 'USD'.
localeBCP 47 tagundefinedLanguage for number and price formats. Without it the browser language is used.
videoBadgebooleantruePlay icon and duration chip on video items.
videoPlay'lightbox' | 'inline''lightbox'Where video items play. 'inline' replaces the thumbnail with the player in the grid. Override per item with data-mb-play. See Skins and captions.
galleryBadgebooleantrueChip with the slide count on items that have a gallery.

Text #

OptionTypeDefaultDescription
i18nobject of stringssee the full listEvery label and message the engine writes. Set only the keys you want to change.

Checking the resolved values #

MediaBoxes.DEFAULTS holds the defaults the build uses, and grid.options the values a grid actually runs with.

js
console.log(MediaBoxes.DEFAULTS.load);   // { mode: 'button', initial: 12, step: 8 }
console.log(document.querySelector('media-boxes').options.columns);