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

Props

Name
Type
Default
Required
number
-

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.

Required
number
-

Height of the collage

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

Render prop for the collage images

Required
number
-

Width of the collage

boolean
false

Whether or not the first image is a cover image

number
0

The amount of vertical & horizontal space between images

number
0

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.

Basic example

Different columns

2 - 4 columns

columns = 2
columns = 3
columns = 4

Gutter

Cover image

Different columns with cover image

2 - 4 columns with cover image

columns = 2
columns = 3
columns = 4

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.

layoutKey = 0
layoutKey = 1
layoutKey = 2
layoutKey = 3