Masonry
Masonry arranges child elements into columns with varying heights, creating a Pinterest-style layout.
Basic Usage
1
2
3
4
5
6
import { Masonry } from "@paramanu/primitives-react"
export default function App() {const heights = [120, 200, 160, 80, 240, 100]return ( <Masonry columns={3} gap="4"> {heights.map((h, i) => ( <div key={i} style={{ background: "#e2e8f0", height: h }}>{i + 1}</div> ))} </Masonry>)}<div class="pm-masonry pm-masonry--cols-3 pm-masonry--gap-4"><div style="background: #e2e8f0; height: 120px;">1</div><div style="background: #e2e8f0; height: 200px;">2</div><div style="background: #e2e8f0; height: 160px;">3</div><div style="background: #e2e8f0; height: 80px;">4</div><div style="background: #e2e8f0; height: 240px;">5</div><div style="background: #e2e8f0; height: 100px;">6</div></div>Accessibility
Masonry is a presentational layout. Ensure content order is logical in the DOM regardless of visual arrangement.
React Props
| Prop | Type | Default | Description |
|---|---|---|---|
columns | 2 | 3 | 4 | 5 | 6 | 3 | Number of columns |
gap | SpacingScale | — | Gap between items |
CSS Classes
| Class | Purpose |
|---|---|
pm-masonry | Container |
pm-masonry--cols-{n} | Column count |
pm-masonry--gap-{n} | Gap size |