shadcn.io is not affiliated with official shadcn/ui
Balanced Waterfall Gallery Block for React
A waterfall of twelve drawn pictures in two, three or four columns on shared hairlines, a switch between shortest-column and round-robin flow, and bars under the wall that read each column's height.
Installation
Overview
A waterfall wall for React with Base UI. Twelve drawn pictures are placed in separate columns on shared hairlines, inside a scrolling window of fixed height. A "Columns" group sets two, three or four columns, and a "Shortest column first" switch chooses the flow: on, each picture goes to the column that is shortest so far; off, the columns are filled in turn. Under the window a ruled band has one bar per column and a readout such as "Heights 1200, 1159, 1159 px, 41 px apart", worked out from the width the wall really has. Each caption carries the picture's place in the reading order. On a phone the wall is two columns in one flow and the controls are hidden. The pictures are drawn in the theme's greys, never photographed. It's built from Guides, Toggle Group and Switch. For image feeds, shops and any wall where even columns matter.
FAQ
How are the columns balanced?
Placements for every column count and both flows are worked out once at module scope, from each picture's ratio, so rendering only picks one. Shortest-first adds each picture to the column with the least height so far; round-robin deals them out in turn. The pictures' ratios are chosen so the two differ clearly.
Where do the heights come from?
A ResizeObserver measures the wall, and each column's height is the sum of its pictures' heights at the width they really have, plus captions, gaps and padding. Until it has measured, the readout uses the widest case.
Why does the wall scroll inside a window?
More columns means a shorter wall, so a free-height wall would move everything below it each time you change the count. The window holds one height; the bars show the full column heights. The window is a labelled, focusable region, so the keyboard can scroll it.
Which keys work?
Related
- Pro
Sortable Masonry Gallery
Masonry and mosaicA masonry wall of twelve drawn pictures of mixed ratio in CSS columns, framed with + marks on its corners, with an Order control (Newest or Oldest) that re-sorts them.
- Pro
Container Query Columns Gallery
Hairline gridsA resizable split, copy and a framed wall of twelve square swatches: drag the divider to change the wall's width and container queries turn two columns into up to five, with a live readout.
- Pro
Hover Caption Masonry Gallery
Masonry and mosaicA masonry wall of nine drawn interiors in three columns, each in its own framed cell, with a caption and a Save toggle that rise on hover and on focus and a live count of saved pictures.
- Pro
Re-lead Mosaic Gallery
Masonry and mosaicA dense mosaic of nine drawn quilt patterns on shared hairlines, eight squares and one lead two cells wide and two tall, with a Lead control that moves the big square while the rest reflow.
- Pro
Density Photo Wall Gallery
Hairline gridsTwenty-four small drawn pictures on shared hairlines whose columns follow a Density slider, each offering one action, Copy link, that confirms in place.
- Pro
A masonry wall of six cards of different heights for a team workspace: a checklist whose boxes really tick, a quick-add bar, a stat, a three-lane board, a set of tags and a thread with a mention.