Reference

Common Props

Props shared by Masonry, MasonryBalanced, and MasonryVirtual.

These props are available on all three components unless noted otherwise.

PropTypeDefaultApplies ToNotes
itemsT[]requiredAllData array rendered by Masonix.
renderComponentType<MasonryRenderProps<T>>requiredAllCard renderer receives index, data, and width.
columnsnumber | Record<number, number>-AllFixed count or responsive container-width map.
columnWidthnumber-AllMinimum width used to compute automatic column count.
maxColumnsnumber-AllCaps automatic or responsive column count.
gapnumber | Record<number, number>0AllRow and column gap in pixels.
defaultColumnsnumber3AllFirst-render fallback when width is unknown.
defaultWidthnumber-AllFirst-render fallback container width.
classNamestring-AllClass on the outer container.
styleCSSProperties-AllInline style on the outer container.
itemClassNamestring-AllClass on every item wrapper.
asElementType"div"AllOuter container element.
itemAsElementType"div"AllItem wrapper element.
itemKey(data: T, index: number) => string | numberindex fallbackAllStable identity for React keys and measurements.
role"list" | "none""list"AllARIA role for the outer container.
aria-labelstring-AllAccessible label for the layout.
announceItemCountChangesbooleanfalseAllAnnounces item-count changes through a polite live region.
refRef<HTMLElement>-AllRef for the outer container.

Render props

interface MasonryRenderProps<T> {
  index: number;
  data: T;
  width: number;
}

Use width when the card needs to compute image height, canvas size, or any other column-aware rendering.

Responsive values

<Masonry
  columns={{ 0: 1, 720: 2, 1080: 3 }}
  gap={{ 0: 8, 720: 12, 1080: 16 }}
/>

Breakpoint keys are minimum container widths in pixels.

Container attributes

Standard HTML attributes not listed above are forwarded to the outer container. This includes id, title, additional aria-* attributes, data-* attributes, and event handlers.

<Masonry
  id="search-results"
  data-layout-owner="search"
  aria-describedby="search-results-description"
  onKeyDown={handleLayoutKeyDown}
  items={results}
  render={ResultCard}
/>

Masonix owns the container children and does not accept dangerouslySetInnerHTML. The role prop remains limited to list and none so the generated item semantics stay valid.

Independent spacing

rowGap and columnGap accept the same numeric or responsive values as gap. Each overrides only its axis; omitted values inherit gap. Column sizing uses columnGap, while vertical placement uses rowGap.

On this page