Skip to content

ContentGrid

Use ContentGrid to display a grid of content, such as products or images, with a set maximum number of columns. When you omit maxColumns, it behaves like a flex container that wraps its children.

The SDK ContentGrid showing content arranged in a grid.
import { ContentGrid } from '/@dropins/tools/components.js';
PropTypeReq?Description
emptyGridContentVNodeYesContent to display when the grid has no children.
maxColumnsnumberNoMaximum number of columns to display. When unset, the grid wraps its children like a flex container.
columnWidthstringNoWidth of each column, as a CSS value such as 1fr or 100px. Defaults to 1fr.
childrenComponentChildrenNoItems to display in the grid. Each child renders in its own grid cell.

ContentGrid also accepts standard HTML attributes (for example, className and onClick).

Render a grid of items, with a fallback for when the list is empty:

import { ContentGrid, provider } from '/@dropins/tools/components.js';
import { h } from '/@dropins/tools/preact.js';
await provider.render(ContentGrid, {
maxColumns: 6,
columnWidth: '1fr',
emptyGridContent: h('div', {}, 'No products found'),
children: yourProducts.map((product) => h('div', { key: product.id }, product.name)),
})(document.querySelector('.contentgrid'));
  • Image — render product photos inside grid cells.
  • Design tokens — the spacing and layout scales the grid uses.