Skip to content

VirtuosoMasonry

ItemContent<Data, Context> = React.ComponentType<{ context: Context; data: Data; index: number; }>

A React component that’s used to render the individual masonry item.

Type ParameterDefault typeDescription
DataanyThe type of items in the data array.
ContextanyOptional contextual data passed from the parent component.

ScrollerProps = Omit<React.HTMLProps<HTMLDivElement>, "data" | "onScroll" | "ref">

The DOM attributes that you can pass to the VirtuosoMasonry component to customize the scroll element.


const VirtuosoMasonry: <Data, Context>(props) => ReactElement

A React component for efficiently rendering large masonry/Pinterest-style layouts with variable-height items distributed across multiple columns. Supports virtualization, window scrolling, and SSR.

Type ParameterDescription
DataThe type of items in the data array passed to the component.
ContextOptional contextual data passed to the ItemContent render callback.
ParameterType
propsVirtuosoMasonryProps<Data, Context> & object

ReactElement


Props for the VirtuosoMasonry component.

Type ParameterDescription
DataThe type of items in the data array passed to the component.
ContextOptional contextual data passed to the ItemContent render callback.

number

The number of columns to be rendered. This prop is required. The component distributes items across columns using a shortest-column-first algorithm.

tsx

Additional data to be passed to the item content component. This prop is optional.


Data[]

The data array to be rendered. This prop is required. Each item will be passed to the ItemContent component for rendering.

tsx

Use this prop for SSR rendering of a pre-defined amount of items.


A React component that renders each individual item in the masonry grid. Receives data, index, and context as props.

tsx

Set to true to make the component use the document scroller instead of creating an element with overflow-y: auto.