Skip to main content

Masonry

Masonry | Creates a responsive 'Masonry' layout of child elements shadow

The Masonry component creates a responsive "Masonry" layout of child elements that are dynamically arranged into columns based on specified attributes. Supports customizing the number of columns, maximum column width, element spacing, and debouncing to optimize performance.

Basic Usage

Maximum width of columns

Use the max-col-width attribute to limit the width of the columns to the specified value.

The Gap

Use the gap attribute to specify the width of the gap between columns in pixels.

Attributes and Properties

inches

DescriptionDefines the number of columns. For auto, selects the number of columns according to the width of the parent.
Attributeinches
Typestring | undefined
Defaultauto

debounce

DescriptionSpecifies the time in ms for the layout to reformat for each change in masonry layout size. This reflow is delayed to prevent the layout algorithm from being invoked too often in succession.
Attributedebounce
Typestring | undefined
Default300

gap

DescriptionDefines the width of the space between columns in pixels.
Attributegap
Typestring | undefined
Default24

max-col-width

DescriptionSets the maximum width of the columns in pixels.
Attributemax-col-width
Typestring | undefined
Default500

Events

No events available for this component.

Methods

No public methods available for this component.

CSS Shadow Parts

NameDescription
columnRefers to all columns inside the element.
column-indexRefers to a specific column element within an element, where index represents the column order. The order starts with zero.
nativeRefers to a div element inside an element.

CSS Custom Properties

NameDescription
--wj-masonry-layout-col-countDefines the number of columns in the masonry layout.
--wj-masonry-layout-gapSpecifies the gap between items in the masonry layout.

Slots

NameDescription
{index}The contents are placed in a column, index represents the column order.