Collage, similarly to Masonry, creates a deterministic grid layout that can absolutely position and virtualize images.

Props

Component props
Name
Type
Default
columns
Required
2 | 3 | 4
-

Number of columns (2 - 4). Note that Collage assumes at least 2 * columns images will be provided. If fewer images are provided, care will be needed to avoid TypeErrors. See Columns example for more details.

height
Required
number
-

Height of the collage.

renderImage
Required
({| width: number, height: number, index: number, |}) => React.Node
-

Callback to render the collage images.

width
Required
number
-

Width of the collage.

cover
boolean
-

Whether or not the first image is a cover image. See Cover Image example for more details.

gutter
number
-

The amount of vertical and horizontal space between images. See Gutter example for more details.

layoutKey
number
-

Depending on the number of columns of the collage, there may be multiple layouts available. If there are N layouts available, (layoutKey % N) will determine which layout is used. See Layout Key example for more details.

Basic example

Different columns

2 - 4 columns

Gutter

Cover image

Different columns with cover image

2 - 4 columns with cover image

Layout key

You can pick a layout using the layout key (layout key is 0 by default). Depending on the number of columns of the collage, there may be multiple layouts available. If there are N layouts available, (layoutKey % N) will determine which layout is used.