Skip to main content

Masonry

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

maxColWidth

DescriptionMaximum column width in pixels. The system automatically calculates the number of columns based on this value and the total width.
Attributemax-col-width
Typenumber
Default500

inches

DescriptionNumber of columns. If the value is set to 'auto', the number of columns is automatically calculated based on the width of the space and the maximum column width.
Attributeinches
Typenumber | string
Default'car'

gap

DescriptionThe space between columns and items in pixels.
Attributegap
Typenumber
Default24

debounce

DescriptionThe time in milliseconds that determines the delay in recalculating the layout after resizing the window.
Attributedebounce
Typenumber
Default300

Events

No events available for this component.

Methods

scheduleLayout

DescriptionSchedules a layout recalculation with a defined delay.
Signature(ms?: number) => void

layout

DescriptionRecalculates the component layout and proves the items into columns based on their height.
Signature() => void

CSS Shadow Parts

NameDescription
nativeRoot element of masonry layout.
columnRefers to the column in the masonry layout.
column-{i}Refers to a specific column in the masonry layout, where 'i' is the column index (0, 1, 2, ...).

CSS Custom Properties

NameDescription
--wje-masonry-gapGap between items in masonry layout. Accepts any valid CSS length value. The default value is 1rem.
--wje-masonry-layout-col-countNumber of columns in masonry layout. The default value is 1.
--wje-masonry-layout-gapGap between columns and items in masonry layout. Accepts any valid CSS length value. The default value is 1rem.

Slots

NameDescription
``Default slot for masonry layout items before deployment.
{i}Dynamically created slots for individual columns, where 'i' is the column index (0, 1, 2, ...). During layout, items are automatically assigned to these slots.