Skip to content

Waterfall

A high-performance Masonry layout component. Its core algorithm uses shortest column balancing and supports image preloading awareness, loading states, empty views, and responsive breakpoints.

Basic Usage

Waterfall Content Card #1

Shortest column balancing algorithm for a cleaner aesthetic.

Waterfall Content Card #5

Staggered entrance animations.

Waterfall Content Card #2

Basic demonstration node.

Waterfall Content Card #6

Basic demonstration node.

Waterfall Content Card #3

Supports image load awareness.

Waterfall Content Card #4

Responsive auto-alignment.

Shortest Column Balance Algorithm

Interaction States

Waterfall Content Card #1
Waterfall Content Card #5
Waterfall Content Card #2
Waterfall Content Card #6
Waterfall Content Card #3
Waterfall Content Card #4
Loading and Empty States

Usage in Nuxt

The Waterfall component fully supports SSR in Nuxt 3/4. When used in a Nuxt project, it is auto-imported.

Waterfall Content Card #1
Waterfall Content Card #5
Waterfall Content Card #2
Waterfall Content Card #6
Waterfall Content Card #3
Waterfall Content Card #4
Nuxt Integration

SSR Considerations:

  • ✅ Supports static rendering on first load to prevent layout shifts.
  • ✅ Responsive column counts automatically adapt to container width after client-side hydration.

Commercial Case: E-commerce Pagination

No Data
Pagination Loading

Commercial Case: Infinite Loading Flow

No Data
Infinite Flow

API

Props

NameDescriptionTypeDefault
itemsData source arrayT[][]
colsColumn count config. Supports a number or responsive object.number | WaterfallCols2
gapGap between cards (px)number16
loadingWhether in loading statebooleanfalse
height-propertyField name for height used for balanced layout. Enables shortest column algorithm if provided.string'height'
img-selectorInternal image selector. Triggers re-calculation after images load.string'img'
animationWhether entrance animations are enabledbooleantrue
delayBase delay for step-up animations (ms)number100
row-keyField name for unique identifierstring'id'
responsiveWhether to automatically listen for container width changesbooleantrue

WaterfallCols Definition

ts
interface WaterfallCols {
  xs?: number // < 576px
  sm?: number // >= 576px
  md?: number // >= 768px
  lg?: number // >= 992px
  xl?: number // >= 1200px
}

Slots

NameDescriptionParameters
defaultCustom node rendering{ item: T, index: number, column: number }
loadingCustom initial loading placeholder (usually skeletons)-
emptyCustom empty state content-
loading-overlayCustom overlay for refresh states (when old data is present)-

Expose

NameDescriptionType
layoutManually trigger layout re-calculation() => void

Theme Variables

Customize local styles by overriding these CSS variables:

Variable NameDescriptionDefault
--yh-bg-color-pageBackground for skeleton nodesvar(--yh-bg-color-page)
--yh-color-text-secondaryEmpty state text colorvar(--yh-text-color-secondary)
--yh-color-primaryLoader rotation color for refresh overlayvar(--yh-color-primary)
--yh-color-primary-light-8Loader orbit background for refresh overlayvar(--yh-color-primary-light-8)

Released under the MIT License.