Grid
A grid component based on CSS Grid layout, providing responsive layouts to make pages adapt to different screen widths more easily. Its functionality is similar to the Flex component. If you prefer Grid layouts, you can try this component.
Basic Usage
The Grid component divides the content area into 24 columns by default, which can be adjusted using the column property. The column property supports responsiveness. Like the Flex component, 'xs', 'sm', 'md', 'lg', 'xl', and 'xxl' correspond to window pixel widths of , , , , , and respectively.
Column 24
Column 16
Responsive
Grid Size
The span property of GridItem sets the grid width.
Grid Offset
The offset property of GridItem sets the grid offset. It also supports responsiveness.
Grid Gutter
The gutter property of Grid sets the spacing between GridItems. It also supports responsiveness.
x: 4px, y: 4px
x: 8px, y: 4px
Responsive
API
GridProps
| Attribute | Type | Optional | Default | Description | Version |
|---|---|---|---|---|---|
| column | number | ValueWithDeviceWidth<number> | True | 24 | Number of columns in the Grid content area. | 0.0.0-beta |
| gutter | number | { x?: number; y?: number } | Value4DeviceWidth<number | { x?: number; y?: number }> | True | 0 | Spacing between GridItem components. | 0.0.0-beta |
GridSlots
| Slot | Parameter | Description | Version |
|---|---|---|---|
| default | | GridItem components. | 0.0.0-beta |
GridItemProps
| Attribute | Type | Optional | Default | Description | Version |
|---|---|---|---|---|---|
| offset | number | ValueWithDeviceWidth<number> | True | 0 | Left offset of GridItem. | 0.0.0-beta |
| span | number | ValueWithDeviceWidth<number> | True | | The width of GridItem defaults to the column attribute of Grid. | 0.0.0-beta |
GridItemSlots
| Slot | Parameter | Description | Version |
|---|---|---|---|
| default | | Content of GridItem. | 0.0.0-beta |
ValueWithDeviceWidth
enum SCREEN_SIZE_TYPE {
XS = 'xs',
SM = 'sm',
MD = 'md',
LG = 'lg',
XL = 'xl',
XXL = 'xxl'
}
type ValueWithDeviceWidth<T> = Record<SCREEN_SIZE_TYPE, T>