Masonry Image

Demo

space man
mars along
night
space cat
cube
man with ballon
imac
hire car
colorful space man
mars
mario
cube 3d

Props

PropTypeDescription
children{ [key: string]: any; src: string; alt: string }[]The array of image objects to be displayed, each with a source and alt text.
breakpointCols{ [key: number]: number; }Configuration for the number of columns based on viewport width.
lightBoxboolean (optional)If true, enables Lightbox functionality for images.
photoItem(item: { [key: string]: any; src: string; alt: string }, index: number) => React.ReactNode (optional)Custom render function for each image.
loadSizenumber (optional)The size to load images at, used for width and height.
aspectRationumber (optional)The aspect ratio for images.
classNames{ masonry?: string; column?: string; image?: string; lightBox?: string } (optional)Custom class names for the masonry grid, columns, images, and Lightbox.

Breakpoint Columns Object

This prop allows for defining the number of columns at specific viewport widths. It accepts either a single number for a fixed number of columns or an object with keys as viewport widths and values as the number of columns.

  • default: Default number of columns.
  • Breakpoints (e.g., 1100, 700, 500): Number of columns for specific viewport widths.

Styles

This component allows for custom styles via the classNames prop:

  • masonry: CSS class for styling the overall Masonry grid.
  • column: CSS class for styling individual columns within the Masonry grid.
  • image: CSS class for styling individual images.
  • lightBox: CSS class for styling the Lightbox component, if enabled.