Pretext Masonry Grid
Text-aware masonry layout where card heights are predicted by Pretext without DOM measurement. Zero layout shift.
@chenglou/pretext
Installation
$ shadcn add @jalco/masonry-gridUsage
import { MasonryGrid } from "@/components/masonry-grid"<MasonryGrid items={items} columns={3} />Client component. Each card's text height is computed by Pretext using pure arithmetic. Cards are absolutely positioned into columns — no DOM measurement, no layout shift.
Examples
Three columns
API Reference
MasonryGrid
PropType
MasonryItem
PropType
Notes
- Pretext-powered. Uses @chenglou/pretext for pure-arithmetic height prediction.
- Zero layout shift. Cards are positioned using computed heights, not DOM measurements. No reflow, no CLS.
- Responsive. Uses
ResizeObserverto recalculate positions when the container width changes. - Font matching. The
fontandlineHeightprops must match the CSS styling of the card body text.