Skip to content

Commit 85794e0

Browse files
committed
chore: update docs
1 parent c6d34fb commit 85794e0

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ npm install react-plock
2323

2424
### Usage
2525

26-
Using Plock with the new v3 APIs it's a piece of cake. Here's an example of how can you create an [Unsplash-Like](https://unsplash.com/) masonry grid. You can even see a demo of this example by clicking [here](https://react-plock.netlify.app/).
26+
Using Plock with the new v3 APIs it's a piece of cake. Here's an example of how can you create a masonry grid. You can even see a demo of this example by clicking [here](https://react-plock-with-vite.vercel.app/).
2727

2828
```tsx
2929
import { Masonry } from 'react-plock';
@@ -47,6 +47,29 @@ const ImagesMasonry = () => {
4747
};
4848
```
4949

50+
### Balanced Layout
51+
52+
React Plock offers a balanced layout option that creates a more visually harmonious masonry grid by considering the height of each item. When enabled with `useBalancedLayout: true`, the layout algorithm distributes items across columns while attempting to minimize height differences between columns.
53+
54+
This is particularly useful for content with varying heights, such as images or cards, where a traditional masonry layout might create uneven columns.
55+
56+
Unlike the default layout which distributes items sequentially, the balanced layout dynamically measures and adjusts item placement to create a more aesthetically pleasing result.
57+
58+
```tsx
59+
<Masonry
60+
items={items}
61+
config={{
62+
columns: [2, 3, 4],
63+
gap: [16, 16, 16],
64+
media: [640, 768, 1024],
65+
useBalancedLayout: true, // Enable balanced layout
66+
}}
67+
render={(item) => (
68+
<img src={item.url} alt={item.alt} style={{ width: '100%' }} />
69+
)}
70+
/>
71+
```
72+
5073
### API Reference
5174

5275
Here's the TypeScript definition for the Masonry Component, below you can find a more detailed explanation.
@@ -59,6 +82,7 @@ export type MasonryProps<T> = React.ComponentPropsWithoutRef<'div'> & {
5982
columns: number | number[];
6083
gap: number | number[];
6184
media?: number[];
85+
useBalancedLayout?: boolean;
6286
};
6387
as?: React.ElementType;
6488
};

0 commit comments

Comments
 (0)