masonix
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"grid" | "list" | "none""list"AllARIA role for the outer container.
aria-labelstring-AllAccessible label for the layout.
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.

On this page