1e41f4b71Sopenharmony_ci# grid-container 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci> **NOTE** 4e41f4b71Sopenharmony_ci> 5e41f4b71Sopenharmony_ci> This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciThe **\<grid-container>** component is the root container of the grid layout. Within the root container, you can use **\<grid-row>** and **\<grid-col>** for the grid layout. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## Required Permissions 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciNone 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci## Child Components 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ciOnly the **\<grid-row>** component is supported. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## Attributes 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-components-common-attributes.md), the following attributes are supported. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci| Name| Type| Default Value| Mandatory| Description| 24e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 25e41f4b71Sopenharmony_ci| columns | string \| number | auto | No| Total number of columns in the grid. If a value of the string type is set, it can only be **auto**. In this case, the total number of columns is determined based on the current **sizetype**, which can be one of the following values:<br>- **xs**: 2 columns<br>- **sm**: 4 columns<br>- **md**: 8 columns<br>- **lg**: 12 columns| 26e41f4b71Sopenharmony_ci| sizetype | string | auto | No| Size-responsive type of the grid. Available values are **xs**, **sm**, **md**, and **lg**. If the default value **auto** is used, the framework automatically selects one of the four types based on the current container size.| 27e41f4b71Sopenharmony_ci| gutter | <length> | 24px | No| Gutter width.| 28e41f4b71Sopenharmony_ci| gridtemplate<sup>6+</sup> | string | default | No| Layout template of the grid, which defines the columns, gutters, and margins for different size-responsive types. This attribute is available when **columns** and **sizetype** are set to **auto**. For details about the values, see **gridtemplate**.| 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci**Table 1** gridtemplate<sup>6+</sup> 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci| | Template Value| Size-responsive Type| Columns | Margins (px) | Gutters (px) | 33e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | -------- | 34e41f4b71Sopenharmony_ci| Default grid| default | xs | 2 | 12 | 12 | 35e41f4b71Sopenharmony_ci| | | sm | 4 | 24 | 24 | 36e41f4b71Sopenharmony_ci| | | md | 8 | 32 | 24 | 37e41f4b71Sopenharmony_ci| | | lg | 12 |48|24| 38e41f4b71Sopenharmony_ci| Grid layout| grid | sm (0 < Device horizontal resolution < 600px)| 4 | 24 | 12 | 39e41f4b71Sopenharmony_ci| | | md | 8 |32|12| 40e41f4b71Sopenharmony_ci| | | lg | 12 |48|12| 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci> **NOTE** 43e41f4b71Sopenharmony_ci> 44e41f4b71Sopenharmony_ci> The px unit is applicable when **autoDesignWidth** is set to **true** in the "js" tag.<sup>6+</sup> 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci## Styles 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ciIn addition to the [universal styles](js-components-common-styles.md), the following styles are supported. 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci| Name| Type| Default Value| Mandatory| Description| 52e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 53e41f4b71Sopenharmony_ci| justify-content | string | flex-start | No| How items are aligned along the main axis of the flex container. Available values are as follows:<br>- **flex-start**: Items are packed towards the start row.<br>- **flex-end**: Items are packed towards the end row.<br>- **center**: Items are centered along the row.<br>- **space-between**: Items are positioned with space between the rows.<br>- **space-around**: Items are positioned with space before, between, and after the rows.| 54e41f4b71Sopenharmony_ci| align-items | string | stretch | No| How items are aligned along the cross axis in a flex container. Available values are as follows:<br>- **stretch**: Items are stretched to the same height or width as the container in the cross axis direction.<br>- **flex-start**: Items are aligned to the start of the cross axis.<br>- **flex-end**: Items are aligned to the end of the cross axis.<br>- **center**: Items are aligned in the center of the cross axis.| 55e41f4b71Sopenharmony_ci| align-content | string | flex-start | No| Multi-row alignment mode when there is extra space in the cross axis. Available values are as follows:<br>- **flex-start**: All rows are packed towards the start of the cross axis. The start edge of the cross axis of the first row is aligned with the start edge of the cross axis of the container. All subsequent rows are aligned with the previous row.<br>- **flex-end**: All rows are packed towards the end of the cross axis. The end of the cross axis of the last row is aligned with the end of the cross axis of the container. All subsequent rows are aligned with the previous row.<br>- **center**: All rows are packed towards the center of the container. Rows are close to each other and aligned with the center of the container. The spacing between the start edge of the container's cross axis and the first row is equal to the spacing between the end edge of the container's cross axis and the last row.<br>- **space-between**: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The start and end edges of the container's cross axis are aligned with the edges of the first and last rows, respectively.<br>- **space-around**: All rows are evenly distributed in the container, and the spacing between two adjacent lines is the same. The spacing between the start edge of the container's cross axis and the first row and that between the end edge and the last row are half of the spacing between two adjacent rows.| 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci## Events 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ciThe [universal events](js-components-common-events.md) are supported. 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci## Methods 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ciIn addition to the [universal methods](js-components-common-methods.md), the following methods are supported. 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci| Name| Parameter| Description| 68e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 69e41f4b71Sopenharmony_ci| getColumns | - | Returns the number of columns in the grid.| 70e41f4b71Sopenharmony_ci| getColumnWidth | - | Returns the column width of the grid.| 71e41f4b71Sopenharmony_ci| getGutterWidth | - | Returns the gutter width between columns of the grid.| 72e41f4b71Sopenharmony_ci| getSizeType | - | Returns the size-responsive type of the grid container (xs\|sm\|md\|lg).| 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci## Example 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ciFor details, see [Example in grid-col](js-components-grid-col.md#example). 78