1e41f4b71Sopenharmony_ci# GridContainer
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **GridContainer** component lays out components vertically. It is used only in the grid layout.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>  This component is deprecated since API version 9. You are advised to use [GridCol](ts-container-gridcol.md) and [GridRow](ts-container-gridrow.md) instead.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## Child Components
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ciSupported
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## APIs
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciGridContainer(value?: { columns?: number | 'auto', sizeType?: SizeType, gutter?: number | string, margin?: number | string})
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**Parameters**
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
24e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
25e41f4b71Sopenharmony_ci| columns | number \| 'auto' | No| Total number of columns in the current layout.<br>Default value: **'auto'**|
26e41f4b71Sopenharmony_ci| sizeType | SizeType | No| Device size type.<br>Default value: **SizeType.Auto**|
27e41f4b71Sopenharmony_ci| gutter | number \| string | No| Gutter of the grid layout. This parameter cannot be set to a percentage.|
28e41f4b71Sopenharmony_ci| margin | number \| string | No| Margin of the grid layout. This parameter cannot be set to a percentage.|
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci## SizeType
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci| Name| Description|
33e41f4b71Sopenharmony_ci| -------- | -------- |
34e41f4b71Sopenharmony_ci| XS | Device of the minimum size.|
35e41f4b71Sopenharmony_ci| SM | Small-sized device.|
36e41f4b71Sopenharmony_ci| MD | Medium-sized device.|
37e41f4b71Sopenharmony_ci| LG | Large-sized device.|
38e41f4b71Sopenharmony_ci| Auto | Auto. The size type is selected based on the device type.|
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci## Attributes
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ciThe universal attributes and attributes of the **[<Column\>](ts-container-column.md#attributes)** component are supported.
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci## Events
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ciThe universal events are supported.
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci## Example
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci```ts
54e41f4b71Sopenharmony_ci// xxx.ets
55e41f4b71Sopenharmony_ci@Entry
56e41f4b71Sopenharmony_ci@Component
57e41f4b71Sopenharmony_cistruct GridContainerExample {
58e41f4b71Sopenharmony_ci  @State sizeType: SizeType = SizeType.XS
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci  build() {
61e41f4b71Sopenharmony_ci    Column({ space: 5 }) {
62e41f4b71Sopenharmony_ci      GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) {
63e41f4b71Sopenharmony_ci        Row() {
64e41f4b71Sopenharmony_ci          Text('1')
65e41f4b71Sopenharmony_ci            .useSizeType({
66e41f4b71Sopenharmony_ci              xs: { span: 6, offset: 0 },
67e41f4b71Sopenharmony_ci              sm: { span: 2, offset: 0 },
68e41f4b71Sopenharmony_ci              md: { span: 2, offset: 0 },
69e41f4b71Sopenharmony_ci              lg: { span: 2, offset: 0 }
70e41f4b71Sopenharmony_ci            })
71e41f4b71Sopenharmony_ci            .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center)
72e41f4b71Sopenharmony_ci          Text('2')
73e41f4b71Sopenharmony_ci            .useSizeType({
74e41f4b71Sopenharmony_ci              xs: { span: 2, offset: 6 },
75e41f4b71Sopenharmony_ci              sm: { span: 6, offset: 2 },
76e41f4b71Sopenharmony_ci              md: { span: 2, offset: 2 },
77e41f4b71Sopenharmony_ci              lg: { span: 2, offset: 2 }
78e41f4b71Sopenharmony_ci            })
79e41f4b71Sopenharmony_ci            .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center)
80e41f4b71Sopenharmony_ci          Text('3')
81e41f4b71Sopenharmony_ci            .useSizeType({
82e41f4b71Sopenharmony_ci              xs: { span: 2, offset: 8 },
83e41f4b71Sopenharmony_ci              sm: { span: 2, offset: 8 },
84e41f4b71Sopenharmony_ci              md: { span: 6, offset: 4 },
85e41f4b71Sopenharmony_ci              lg: { span: 2, offset: 4 }
86e41f4b71Sopenharmony_ci            })
87e41f4b71Sopenharmony_ci            .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center)
88e41f4b71Sopenharmony_ci          Text('4')
89e41f4b71Sopenharmony_ci            .useSizeType({
90e41f4b71Sopenharmony_ci              xs: { span: 2, offset: 10 },
91e41f4b71Sopenharmony_ci              sm: { span: 2, offset: 10 },
92e41f4b71Sopenharmony_ci              md: { span: 2, offset: 10 },
93e41f4b71Sopenharmony_ci              lg: { span: 6, offset: 6 }
94e41f4b71Sopenharmony_ci            })
95e41f4b71Sopenharmony_ci            .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center)
96e41f4b71Sopenharmony_ci        }
97e41f4b71Sopenharmony_ci      }.width('90%')
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci      Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC)
100e41f4b71Sopenharmony_ci      Row() {
101e41f4b71Sopenharmony_ci        Button('XS')
102e41f4b71Sopenharmony_ci          .onClick(() => {
103e41f4b71Sopenharmony_ci            this.sizeType = SizeType.XS
104e41f4b71Sopenharmony_ci          }).backgroundColor(0x317aff)
105e41f4b71Sopenharmony_ci        Button('SM')
106e41f4b71Sopenharmony_ci          .onClick(() => {
107e41f4b71Sopenharmony_ci            this.sizeType = SizeType.SM
108e41f4b71Sopenharmony_ci          }).backgroundColor(0x317aff)
109e41f4b71Sopenharmony_ci        Button('MD')
110e41f4b71Sopenharmony_ci          .onClick(() => {
111e41f4b71Sopenharmony_ci            this.sizeType = SizeType.MD
112e41f4b71Sopenharmony_ci          }).backgroundColor(0x317aff)
113e41f4b71Sopenharmony_ci        Button('LG')
114e41f4b71Sopenharmony_ci          .onClick(() => {
115e41f4b71Sopenharmony_ci            this.sizeType = SizeType.LG
116e41f4b71Sopenharmony_ci          }).backgroundColor(0x317aff)
117e41f4b71Sopenharmony_ci      }
118e41f4b71Sopenharmony_ci    }.width('100%').margin({ top: 5 })
119e41f4b71Sopenharmony_ci  }
120e41f4b71Sopenharmony_ci}
121e41f4b71Sopenharmony_ci```
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci![en-us_image_0000001256858425](figures/en-us_image_0000001256858425.gif)
124