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:
The engine defaults. A <script type="application/json" data-mb-options> block inside the element. HTML attributes on the element (only the options listed in HTML attributes ). 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 Copy
const grid = document.querySelector('media-boxes' );
grid.options = { columns: 5 , lightbox: { download: true } }; // merged, not replaced
console.log(grid.options.lightbox.loop); // true
Layout #
Option Type Default Description 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 null nullnull derives them from columns. An array, even [], is used exactly as given. They match the width of the element.
Appearance #
Option Type Default Description 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 #
Option Type Default Description load.mode'all' | 'button' | 'scroll' | 'pages''button'How the items are revealed. See Loading . load.initialinteger, 1 or more 12Items shown first, and the page size in pages mode. load.stepinteger, 1 or more 8Items added per load in button and scroll modes.
Filters, search and sort #
Option Type Default Description 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'.
Deep links #
Option Type Default Description deepLink.filterboolean trueStore the filters and sort in the address. deepLink.searchboolean falseStore the search text. deepLink.lightboxboolean trueStore 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 .
Lightbox #
All of these live under lightbox. They are explained in Lightbox . lightbox: false turns the whole lightbox off.
Option Type Default Description lightbox.enabledboolean trueOpen items in the lightbox. lightbox.scope'filtered' | 'all''filtered'Which items the visitor can flip through. lightbox.loopboolean trueWrap around at the ends (more than two slides). lightbox.counterboolean trueShow the position counter. lightbox.captionsboolean trueShow title and caption. lightbox.thumbnailsboolean trueShow the thumbnail strip. lightbox.zoomboolean trueAllow zooming. lightbox.fullscreenboolean trueShow the fullscreen button. lightbox.downloadboolean falseShow the download button. lightbox.shareboolean falseShow the share button. lightbox.transition'slide' | 'fade''slide'Movement between slides. lightbox.openAnimation'zoom' | 'fade''zoom'How the lightbox opens and closes. lightbox.swipeToCloseboolean trueDrag 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 5 1Slides loaded on each side of the current one. lightbox.slideshow.enabledboolean trueShow the slideshow button. lightbox.slideshow.autoStartboolean falsePlay as soon as it opens. lightbox.slideshow.intervalnumber (ms) 4000Time per slide. lightbox.slideshow.pauseOnHoverboolean falsePause while the mouse is over the stage.
Option Type Default Description itemsarray of item objects none Items 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 tag undefinedLanguage for number and price formats. Without it the browser language is used. videoBadgeboolean truePlay 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 . galleryBadgeboolean trueChip with the slide count on items that have a gallery.
Text #
Option Type Default Description i18nobject of strings see the full list Every 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 Copy
console.log(MediaBoxes.DEFAULTS.load); // { mode: 'button', initial: 12, step: 8 }
console.log(document.querySelector('media-boxes' ).options.columns);