2016-08-08 10:40:02 +08:00
---
category: Components
2022-11-09 12:28:04 +08:00
group: Layout
2016-11-09 14:43:32 +08:00
title: Grid
2020-05-31 11:48:34 +08:00
cover: https://gw.alipayobjects.com/zos/alicdn/5rWLU27so/Grid.svg
2016-08-08 10:40:02 +08:00
---
2020-08-14 10:58:58 +08:00
24 Grids System.
2016-08-08 10:40:02 +08:00
## Design concept
2016-11-09 14:43:32 +08:00
< div class = "grid-demo" >
2022-03-29 19:46:16 +08:00
< img src = "https://gw.alipayobjects.com/zos/bmw-prod/9189c9ef-c601-40dc-9960-c11dbb681888.svg" alt = "grid design" / >
2016-08-08 10:40:02 +08:00
< / div >
2019-08-03 19:52:31 +08:00
In most business situations, Ant Design needs to solve a lot of information storage problems within the design area, so based on 12 Grids System, we divided the design area into 24 sections.
2016-08-08 10:40:02 +08:00
2017-09-08 09:42:08 +08:00
We name the divided area 'box'. We suggest four boxes for horizontal arrangement at most, one at least. Boxes are proportional to the entire screen as shown in the picture above. To ensure a high level of visual comfort, we customize the typography inside of the box based on the box unit.
2016-08-08 10:40:02 +08:00
## Outline
2017-09-08 09:42:08 +08:00
In the grid system, we define the frame outside the information area based on `row` and `column` , to ensure that every area can have stable arrangement.
2016-08-08 10:40:02 +08:00
Following is a brief look at how it works:
2020-08-14 10:58:58 +08:00
- Establish a set of `column` in the horizontal space defined by `row` (abbreviated col).
- Your content elements should be placed directly in the `col` , and only `col` should be placed directly in `row` .
2019-10-18 18:50:33 +08:00
- The column grid system is a value of 1-24 to represent its range spans. For example, three columns of equal width can be created by `<Col span={8} />` .
2017-10-25 10:25:44 +08:00
- If the sum of `col` spans in a `row` are more than 24, then the overflowing `col` as a whole will start a new line arrangement.
2016-08-08 10:40:02 +08:00
2019-11-20 11:13:24 +08:00
Our grid systems base on Flex layout to allow the elements within the parent to be aligned horizontally - left, center, right, wide arrangement, and decentralized arrangement. The Grid system also supports vertical alignment - top aligned, vertically centered, bottom-aligned. You can also define the order of elements by using `order` .
2016-08-08 10:40:02 +08:00
2019-11-20 11:13:24 +08:00
Layout uses a 24 grid layout to define the width of each "box", but does not rigidly adhere to the grid layout.
2016-08-08 10:40:02 +08:00
2022-11-09 12:28:04 +08:00
## Examples
2022-11-17 17:31:26 +08:00
<!-- prettier - ignore -->
2022-11-09 12:28:04 +08:00
< code src = "./demo/basic.tsx" > Basic Grid< / code >
< code src = "./demo/gutter.tsx" > Grid Gutter< / code >
< code src = "./demo/offset.tsx" > Column offset< / code >
< code src = "./demo/sort.tsx" > Grid sort< / code >
< code src = "./demo/flex.tsx" > Typesetting< / code >
< code src = "./demo/flex-align.tsx" > Alignment< / code >
< code src = "./demo/flex-order.tsx" > Order< / code >
< code src = "./demo/flex-stretch.tsx" > Flex Stretch< / code >
< code src = "./demo/responsive.tsx" > Responsive< / code >
< code src = "./demo/responsive-more.tsx" > More responsive< / code >
< code src = "./demo/playground.tsx" > Playground< / code >
2022-11-16 16:02:54 +08:00
< code src = "./demo/useBreakpoint.tsx" > useBreakpoint Hook< / code >
2022-11-09 12:28:04 +08:00
2016-08-08 10:40:02 +08:00
## API
2017-09-08 09:42:08 +08:00
If the Ant Design grid layout component does not meet your needs, you can use the excellent layout components of the community:
2016-08-08 10:40:02 +08:00
- [react-flexbox-grid ](http://roylee0704.github.io/react-flexbox-grid/ )
2017-08-23 16:34:15 +08:00
- [react-blocks ](https://github.com/whoisandy/react-blocks/ )
2016-08-08 10:40:02 +08:00
### Row
2022-11-17 17:31:26 +08:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| align | Vertical alignment | `top` \| `middle` \| `bottom` \| `stretch` \| `{[key in 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| 'xxl']: 'top' \| 'middle' \| 'bottom' \| 'stretch'}` | `top` | object: 4.24.0 |
| gutter | Spacing between grids, could be a number or a object like { xs: 8, sm: 16, md: 24}. Or you can use array to make horizontal and vertical spacing work at the same time `[horizontal, vertical]` | number \| object \| array | 0 | |
| justify | Horizontal arrangement | `start` \| `end` \| `center` \| `space-around` \| `space-between` \| `space-evenly` \| `{[key in 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| 'xxl']: 'start' \| 'end' \| 'center' \| 'space-around' \| 'space-between' \| 'space-evenly'}` | `start` | object: 4.24.0 |
| wrap | Auto wrap line | boolean | true | 4.8.0 |
2016-08-08 10:40:02 +08:00
### Col
2022-11-17 17:31:26 +08:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| flex | Flex layout style | string \| number | - | |
| offset | The number of cells to offset Col from the left | number | 0 | |
| order | Raster order | number | 0 | |
| pull | The number of cells that raster is moved to the left | number | 0 | |
| push | The number of cells that raster is moved to the right | number | 0 | |
| span | Raster number of cells to occupy, 0 corresponds to `display: none` | number | none | |
| xs | `screen < 576px` and also default setting, could be a `span` value or an object containing above props | number \| object | - | |
| sm | `screen ≥ 576px` , could be a `span` value or an object containing above props | number \| object | - | |
| md | `screen ≥ 768px` , could be a `span` value or an object containing above props | number \| object | - | |
| lg | `screen ≥ 992px` , could be a `span` value or an object containing above props | number \| object | - | |
| xl | `screen ≥ 1200px` , could be a `span` value or an object containing above props | number \| object | - | |
| xxl | `screen ≥ 1600px` , could be a `span` value or an object containing above props | number \| object | - | |
2017-09-08 09:42:08 +08:00
2020-02-14 16:01:44 +08:00
The breakpoints of responsive grid follow [BootStrap 4 media queries rules ](https://getbootstrap.com/docs/4.0/layout/overview/#responsive-breakpoints ) (not including `occasionally part` ).
2019-12-23 20:07:56 +08:00
< style >
[data-theme="dark"] #components -grid-demo-playground pre {
background: rgba(255,255,255,0.8);
color: rgba(255,255,255,.65);
}
< / style >