Common Props
Props shared by Masonry, MasonryBalanced, and MasonryVirtual.
These props are available on all three components unless noted otherwise.
| Prop | Type | Default | Applies To | Notes |
|---|---|---|---|---|
items | T[] | required | All | Data array rendered by Masonix. |
render | ComponentType<MasonryRenderProps<T>> | required | All | Card renderer receives index, data, and width. |
columns | number | Record<number, number> | - | All | Fixed count or responsive container-width map. |
columnWidth | number | - | All | Minimum width used to compute automatic column count. |
maxColumns | number | - | All | Caps automatic or responsive column count. |
gap | number | Record<number, number> | 0 | All | Row and column gap in pixels. |
defaultColumns | number | 3 | All | First-render fallback when width is unknown. |
defaultWidth | number | - | All | First-render fallback container width. |
className | string | - | All | Class on the outer container. |
style | CSSProperties | - | All | Inline style on the outer container. |
itemClassName | string | - | All | Class on every item wrapper. |
as | ElementType | "div" | All | Outer container element. |
itemAs | ElementType | "div" | All | Item wrapper element. |
itemKey | (data: T, index: number) => string | number | index fallback | All | Stable identity for React keys and measurements. |
role | "list" | "none" | "list" | All | ARIA role for the outer container. |
aria-label | string | - | All | Accessible label for the layout. |
announceItemCountChanges | boolean | false | All | Announces item-count changes through a polite live region. |
ref | Ref<HTMLElement> | - | All | Ref 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.