1# Column
2
3The **Column** component lays out child components vertically.
4
5>  **NOTE**
6>
7>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8
9
10## Child Components
11
12Supported
13
14
15## APIs
16
17Column(value?: {space?: string | number})
18
19**Widget capability**: This API can be used in ArkTS widgets since API version 9.
20
21**Atomic service API**: This API can be used in atomic services since API version 11.
22
23**System capability**: SystemCapability.ArkUI.ArkUI.Full
24
25**Parameters**
26
27| Name| Type| Mandatory| Description|
28| -------- | -------- | -------- | -------- |
29| space | string \| number | No| Vertical spacing between two adjacent child components.<br>Since API version 9, this parameter does not take effect when it is set to a negative number or when [justifyContent](ts-container-column.md#justifycontent8) is set to **FlexAlign.SpaceBetween**, **FlexAlign.SpaceAround**, or **FlexAlign.SpaceEvenly**.<br>Default value: **0**<br>Unit: vp<br>**NOTE**<br>The value can be a number greater than or equal to 0 or a string that can be converted to a number.|
30
31## Attributes
32
33In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
34
35### alignItems
36
37alignItems(value: HorizontalAlign)
38
39Alignment mode of the child components in the horizontal direction.
40
41**Widget capability**: This API can be used in ArkTS widgets since API version 9.
42
43**Atomic service API**: This API can be used in atomic services since API version 11.
44
45**System capability**: SystemCapability.ArkUI.ArkUI.Full
46
47**Parameters**
48
49| Name| Type                                                   | Mandatory| Description                                                        |
50| ------ | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
51| value  | [HorizontalAlign](ts-appendix-enums.md#horizontalalign) | Yes  | Alignment mode of child components in the horizontal direction.<br>Default value: **HorizontalAlign.Center**|
52
53### justifyContent<sup>8+</sup>
54
55justifyContent(value: FlexAlign)
56
57Alignment mode of the child components in the vertical direction.
58
59**Widget capability**: This API can be used in ArkTS widgets since API version 9.
60
61**Atomic service API**: This API can be used in atomic services since API version 11.
62
63**System capability**: SystemCapability.ArkUI.ArkUI.Full
64
65**Parameters**
66
67| Name| Type                                       | Mandatory| Description                                                      |
68| ------ | ------------------------------------------- | ---- | ---------------------------------------------------------- |
69| value  | [FlexAlign](ts-appendix-enums.md#flexalign) | Yes  | Alignment mode of child components in the vertical direction.<br>Default value: **FlexAlign.Start**|
70
71>  **NOTE**
72>
73>  During column layout, child components do not shrink if [flexShrink](ts-universal-attributes-flex-layout.md#flexshrink) is not set for them. In this case, the total size of the child components on the main axis can exceed the size of the container on the main axis.
74
75### reverse<sup>12+</sup>
76
77reverse(isReversed: Optional\<boolean\>)
78
79Sets whether to reverse the arrangement of child components on the main axis (vertical direction).
80
81**Widget capability**: This API can be used in ArkTS widgets since API version 12.
82
83**Atomic service API**: This API can be used in atomic services since API version 12.
84
85**System capability**: SystemCapability.ArkUI.ArkUI.Full
86
87**Parameters**
88
89| Name| Type                                       | Mandatory| Description                                                      |
90| ------ | ------------------------------------------- | ---- | ---------------------------------------------------------- |
91| isReversed  | Optional\<boolean\> | Yes  | Whether to reverse the arrangement of child components on the main axis (vertical direction).<br>Default value: **true**|
92
93>  **NOTE**
94>
95>  If the **reverse** attribute is not set, the arrangement on the main axis remains in the normal order. If the attribute is set to **undefined**, it defaults to **true**, which reverses the arrangement on the main axis.<br>The **direction** attribute only changes the cross axis direction of the column and does not impact the main axis direction. Therefore, it is independent of the **reverse** attribute.
96
97## Events
98
99The [universal events](ts-universal-events-click.md) are supported.
100
101## Example
102
103```ts
104// xxx.ets
105@Entry
106@Component
107struct ColumnExample {
108  build() {
109    Column({ space: 5 }) {
110      // Set the vertical spacing between two adjacent child components to 5.
111      Text('space').width('90%')
112      Column({ space: 5 }) {
113        Column().width('100%').height(30).backgroundColor(0xAFEEEE)
114        Column().width('100%').height(30).backgroundColor(0x00FFFF)
115      }.width('90%').height(100).border({ width: 1 })
116
117      // Set the alignment mode of the child components in the horizontal direction.
118      Text('alignItems(Start)').width('90%')
119      Column() {
120        Column().width('50%').height(30).backgroundColor(0xAFEEEE)
121        Column().width('50%').height(30).backgroundColor(0x00FFFF)
122      }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 })
123
124      Text('alignItems(End)').width('90%')
125      Column() {
126        Column().width('50%').height(30).backgroundColor(0xAFEEEE)
127        Column().width('50%').height(30).backgroundColor(0x00FFFF)
128      }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 })
129
130      Text('alignItems(Center)').width('90%')
131      Column() {
132        Column().width('50%').height(30).backgroundColor(0xAFEEEE)
133        Column().width('50%').height(30).backgroundColor(0x00FFFF)
134      }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 })
135
136      // Set the alignment mode of the child components in the vertical direction.
137      Text('justifyContent(Center)').width('90%')
138      Column() {
139        Column().width('90%').height(30).backgroundColor(0xAFEEEE)
140        Column().width('90%').height(30).backgroundColor(0x00FFFF)
141      }.height(100).border({ width: 1 }).justifyContent(FlexAlign.Center)
142
143      Text('justifyContent(End)').width('90%')
144      Column() {
145        Column().width('90%').height(30).backgroundColor(0xAFEEEE)
146        Column().width('90%').height(30).backgroundColor(0x00FFFF)
147      }.height(100).border({ width: 1 }).justifyContent(FlexAlign.End)
148    }.width('100%').padding({ top: 5 })
149  }
150}
151```
152
153![column](figures/column.png)
154