Masonry
Masonry
Importimport { Masonry } from 'antd'; |
Versionsupported since 6.0.0 |
![]() |
VOOZH | about |
A masonry layout component for displaying content with different heights.
Common props ref:Common props
| Property | Description | Type | Default | Version | Global Config |
|---|---|---|---|---|---|
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> | - | 6.0.0 | 6.0.0 |
| columns | Number of columns, can be a fixed value or a responsive configuration | number | { xs?: number; sm?: number; md?: number } | 3 | × | |
| fresh | Whether to continuously monitor the size changes of child items | boolean | false | × | |
| gutter | Spacing, can be a fixed value, responsive configuration, or a configuration for horizontal and vertical spacing | Gap | [Gap, Gap] | 0 | × | |
| items | Masonry items | MasonryItem[] | - | × | |
| itemRender | Custom item rendering function | (item: MasonryItem) => React.ReactNode | - | × | |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> | - | 6.0.0 | 6.0.0 |
| onLayoutChange | Callback for column sorting changes | ({ key: React.Key; column: number }[]) => void | - | × |
| Property | Description | Type | Default Value |
|---|---|---|---|
| children | Custom display content, takes precedence over itemRender | React.ReactNode | - |
| column | Specifies the column to which the item belongs | number | - |
| data | Custom data storage | T | - |
| height | Height of the item | number | - |
| key | Unique identifier for the item | string | number | - |
Gap represents the spacing between items. It can either be a fixed value or a responsive configuration.
typeGap=undefined|number| Partial<Record<'xs'|'sm'|'md'|'lg'|'xl'|'xxl',number>>;
| Token Name | Description | Type | Default Value |
|---|---|---|---|
| motionDurationFast | Motion speed, fast speed. Used for small element animation interaction. | string | 0.1s |
| motionDurationSlow | Motion speed, slow speed. Used for large element animation interaction. | string | 0.3s |
| motionEaseOut | Preset motion curve. | string | cubic-bezier(0.215, 0.61, 0.355, 1) |
Basic usage. Set number of columns with columns and spacing with gutter.
Responsive layout adapts to different screen widths. Use columns to specify the number of columns at different breakpoints, and gutter to adjust spacing between items.
Dynamically adjust the height of images as they load.
Demonstrate how masonry layout updates dynamically. Use item.column to keep items in place.
You can customize the semantic dom style of Masonry by passing objects/functions through classNames and styles.