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.

When to use

Use wje-masonry to compose stable page structure with clear visual and semantic hierarchy.

When not to use

Do not use layout components to handle business logic or application orchestration.

Accessibility

Preserve document semantics (header, main, aside, footer) and logical tab/focus order.

Best Practices

  • Define mobile/desktop breakpoints first, then refine visual details.
  • Prefer spacing tokens over ad-hoc margin/padding overrides.
  • Test keyboard and screen reader behavior for overflow scenarios.

Attributes and Properties

maxColWidth

DescriptionGetter for the maxColWidth property.
Attributemax-col-width
Typenumber
Default-

gap

DescriptionGetter for the gap property.
Attributegap
Typenumber
Default-

cols

DescriptionGetter for the cols property.
Attributecols
Typenumber
Default-

Events

No events available for this component.

Methods

renderCols

DescriptionRenders the columns.
Signature(colCount: number) => void

scheduleLayout

DescriptionSchedules a layout.
Signature(ms: number) => void

CSS Shadow Parts

NameDescription
nativeThe native part of the masonry layout.
columnThe individual columns in the masonry layout.

CSS Custom Properties

NameDescription
--wje-masonry-layout-gapThe gap between items in the masonry layout. Accepts any valid CSS length. Default is 1rem.
--wje-masonry-layout-col-countThe count column in the masonry layout. Accepts any valid CSS length.

Slots

NameDescription
defaultThe default slot for the masonry layout.