shadcn.io is not affiliated with official shadcn/ui
Balanced Waterfall Gallery Block for Ark UI
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 Ark 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.