1e41f4b71Sopenharmony_ci# Flex
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **Flex** component allows for flexible layout of child components.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> - The **Flex** component adapts the layout of flex items during rendering. This may affect the performance. Therefore, you are advised to use [Column](ts-container-column.md) or [Row](ts-container-row.md) instead under scenarios where consistently high performance is required.
9e41f4b71Sopenharmony_ci> - If the main axis of the **Flex** component is not set, it follows the size of the parent container. On the contrary, if the main axis of the [Column](ts-container-column.md) or [Row](ts-container-row.md) component is not set, it follows the size of their child component.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## Child Components
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ciSupported
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## APIs
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciFlex(value?: FlexOptions)
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciCreates a standard **Flex** component. For details, see [Flex Layout](../../../ui/arkts-layout-development-flex-layout.md).
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**Parameters**
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci| Name           | Type       | Mandatory  | Description                                    |
30e41f4b71Sopenharmony_ci| -------------- | ---------------------------------------- | ---- |  ---------------------------------------- |
31e41f4b71Sopenharmony_ci| value      | [FlexOptions](#flexoptions) | No   |  Parameters of the child components in the **Flex** component.              |
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci## FlexOptions
34e41f4b71Sopenharmony_ci| Name           | Type                                    | Mandatory  | Default Value              | Description                                    |
35e41f4b71Sopenharmony_ci| -------------- | ---------------------------------------- | ---- | ----------------- | ---------------------------------------- |
36e41f4b71Sopenharmony_ci| direction      | [FlexDirection](ts-appendix-enums.md#flexdirection) | No   | FlexDirection.Row | Direction in which child components are arranged in the **Flex** component, that is, the direction of the main axis.                |
37e41f4b71Sopenharmony_ci| wrap           | [FlexWrap](ts-appendix-enums.md#flexwrap) | No   | FlexWrap.NoWrap   | Whether the **Flex** component has a single line or multiple lines.<br>**NOTE**<br>When wrapped onto multiple lines, the child elements on the new line are stacked in the direction based on the cross axis direction.|
38e41f4b71Sopenharmony_ci| justifyContent | [FlexAlign](ts-appendix-enums.md#flexalign) | No   | FlexAlign.Start   | Alignment mode of the child components in the **Flex** component along the main axis.                   |
39e41f4b71Sopenharmony_ci| alignItems     | [ItemAlign](ts-appendix-enums.md#itemalign) | No   | ItemAlign.Start   | Alignment mode of the child components in the **Flex** component along the cross axis.                  |
40e41f4b71Sopenharmony_ci| alignContent   | [FlexAlign](ts-appendix-enums.md#flexalign) | No   | FlexAlign.Start   | Alignment mode of the child components in a multi-row **Flex** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**.|
41e41f4b71Sopenharmony_ci| space<sup>12+</sup>          | [FlexSpaceOptions](ts-appendix-enums.md#flexspaceoptions12) | No  | {main:LengthMetrics.px(0), cross:LengthMetrics.px(0)} | Space of all child components on the main axis or cross axis of the **Flex** component.<br>This parameter does not take effect if the value specified is a negative number or percentage, or if **justifyContent** is set to **FlexAlign.SpaceBetween**, **FlexAlign.SpaceAround**, or **FlexAlign.SpaceEvenly**.<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.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci## Example
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci### Example 1
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci```ts
48e41f4b71Sopenharmony_ci// xxx.ets
49e41f4b71Sopenharmony_ci@Entry
50e41f4b71Sopenharmony_ci@Component
51e41f4b71Sopenharmony_cistruct FlexExample1 {
52e41f4b71Sopenharmony_ci  build() {
53e41f4b71Sopenharmony_ci    Column() {
54e41f4b71Sopenharmony_ci      Column({ space: 5 }) {
55e41f4b71Sopenharmony_ci        Text('direction:Row').fontSize(9).fontColor(0xCCCCCC).width('90%')
56e41f4b71Sopenharmony_ci        Flex({ direction: FlexDirection.Row }) { // The child components are arranged in the same direction as the main axis runs along the rows.
57e41f4b71Sopenharmony_ci          Text('1').width('20%').height(50).backgroundColor(0xF5DEB3)
58e41f4b71Sopenharmony_ci          Text('2').width('20%').height(50).backgroundColor(0xD2B48C)
59e41f4b71Sopenharmony_ci          Text('3').width('20%').height(50).backgroundColor(0xF5DEB3)
60e41f4b71Sopenharmony_ci          Text('4').width('20%').height(50).backgroundColor(0xD2B48C)
61e41f4b71Sopenharmony_ci        }
62e41f4b71Sopenharmony_ci        .height(70)
63e41f4b71Sopenharmony_ci        .width('90%')
64e41f4b71Sopenharmony_ci        .padding(10)
65e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci        Text('direction:RowReverse').fontSize(9).fontColor(0xCCCCCC).width('90%')
68e41f4b71Sopenharmony_ci        Flex({ direction: FlexDirection.RowReverse }) { // The child components are arranged opposite to the Row direction.
69e41f4b71Sopenharmony_ci          Text('1').width('20%').height(50).backgroundColor(0xF5DEB3)
70e41f4b71Sopenharmony_ci          Text('2').width('20%').height(50).backgroundColor(0xD2B48C)
71e41f4b71Sopenharmony_ci          Text('3').width('20%').height(50).backgroundColor(0xF5DEB3)
72e41f4b71Sopenharmony_ci          Text('4').width('20%').height(50).backgroundColor(0xD2B48C)
73e41f4b71Sopenharmony_ci        }
74e41f4b71Sopenharmony_ci        .height(70)
75e41f4b71Sopenharmony_ci        .width('90%')
76e41f4b71Sopenharmony_ci        .padding(10)
77e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci        Text('direction:Column').fontSize(9).fontColor(0xCCCCCC).width('90%')
80e41f4b71Sopenharmony_ci        Flex({ direction: FlexDirection.Column }) { // The child components are arranged in the same direction as the main axis runs down the columns.
81e41f4b71Sopenharmony_ci          Text('1').width('100%').height(40).backgroundColor(0xF5DEB3)
82e41f4b71Sopenharmony_ci          Text('2').width('100%').height(40).backgroundColor(0xD2B48C)
83e41f4b71Sopenharmony_ci          Text('3').width('100%').height(40).backgroundColor(0xF5DEB3)
84e41f4b71Sopenharmony_ci          Text('4').width('100%').height(40).backgroundColor(0xD2B48C)
85e41f4b71Sopenharmony_ci        }
86e41f4b71Sopenharmony_ci        .height(160)
87e41f4b71Sopenharmony_ci        .width('90%')
88e41f4b71Sopenharmony_ci        .padding(10)
89e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci        Text('direction:ColumnReverse').fontSize(9).fontColor(0xCCCCCC).width('90%')
92e41f4b71Sopenharmony_ci        Flex({ direction: FlexDirection.ColumnReverse }) { // The child components are arranged opposite to the Column direction.
93e41f4b71Sopenharmony_ci          Text('1').width('100%').height(40).backgroundColor(0xF5DEB3)
94e41f4b71Sopenharmony_ci          Text('2').width('100%').height(40).backgroundColor(0xD2B48C)
95e41f4b71Sopenharmony_ci          Text('3').width('100%').height(40).backgroundColor(0xF5DEB3)
96e41f4b71Sopenharmony_ci          Text('4').width('100%').height(40).backgroundColor(0xD2B48C)
97e41f4b71Sopenharmony_ci        }
98e41f4b71Sopenharmony_ci        .height(160)
99e41f4b71Sopenharmony_ci        .width('90%')
100e41f4b71Sopenharmony_ci        .padding(10)
101e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
102e41f4b71Sopenharmony_ci      }.width('100%').margin({ top: 5 })
103e41f4b71Sopenharmony_ci    }.width('100%')
104e41f4b71Sopenharmony_ci  }
105e41f4b71Sopenharmony_ci}
106e41f4b71Sopenharmony_ci```
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci![en-us_image_0000001219744189](figures/en-us_image_0000001219744189.PNG)
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci### Example 2
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci```ts
113e41f4b71Sopenharmony_ci// xxx.ets
114e41f4b71Sopenharmony_ci@Entry
115e41f4b71Sopenharmony_ci@Component
116e41f4b71Sopenharmony_cistruct FlexExample2 {
117e41f4b71Sopenharmony_ci  build() {
118e41f4b71Sopenharmony_ci    Column() {
119e41f4b71Sopenharmony_ci      Column({ space: 5 }) {
120e41f4b71Sopenharmony_ci        Text('Wrap').fontSize(9).fontColor(0xCCCCCC).width('90%')
121e41f4b71Sopenharmony_ci        Flex({ wrap: FlexWrap.Wrap }) { // The child components are arranged in multiple lines.
122e41f4b71Sopenharmony_ci          Text('1').width('50%').height(50).backgroundColor(0xF5DEB3)
123e41f4b71Sopenharmony_ci          Text('2').width('50%').height(50).backgroundColor(0xD2B48C)
124e41f4b71Sopenharmony_ci          Text('3').width('50%').height(50).backgroundColor(0xD2B48C)
125e41f4b71Sopenharmony_ci        }
126e41f4b71Sopenharmony_ci        .width('90%')
127e41f4b71Sopenharmony_ci        .padding(10)
128e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci        Text('NoWrap').fontSize(9).fontColor(0xCCCCCC).width('90%')
131e41f4b71Sopenharmony_ci        Flex({ wrap: FlexWrap.NoWrap }) { // The child components are arranged in a single line.
132e41f4b71Sopenharmony_ci          Text('1').width('50%').height(50).backgroundColor(0xF5DEB3)
133e41f4b71Sopenharmony_ci          Text('2').width('50%').height(50).backgroundColor(0xD2B48C)
134e41f4b71Sopenharmony_ci          Text('3').width('50%').height(50).backgroundColor(0xF5DEB3)
135e41f4b71Sopenharmony_ci        }
136e41f4b71Sopenharmony_ci        .width('90%')
137e41f4b71Sopenharmony_ci        .padding(10)
138e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci        Text('WrapReverse').fontSize(9).fontColor(0xCCCCCC).width('90%')
141e41f4b71Sopenharmony_ci        Flex({ wrap: FlexWrap.WrapReverse , direction:FlexDirection.Row }) { // The child components are reversely arranged in multiple lines, and they may overflow.
142e41f4b71Sopenharmony_ci          Text('1').width('50%').height(50).backgroundColor(0xF5DEB3)
143e41f4b71Sopenharmony_ci          Text('2').width('50%').height(50).backgroundColor(0xD2B48C)
144e41f4b71Sopenharmony_ci          Text('3').width('50%').height(50).backgroundColor(0xD2B48C)
145e41f4b71Sopenharmony_ci        }
146e41f4b71Sopenharmony_ci        .width('90%')
147e41f4b71Sopenharmony_ci        .height(120)
148e41f4b71Sopenharmony_ci        .padding(10)
149e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
150e41f4b71Sopenharmony_ci      }.width('100%').margin({ top: 5 })
151e41f4b71Sopenharmony_ci    }.width('100%')
152e41f4b71Sopenharmony_ci  }
153e41f4b71Sopenharmony_ci}
154e41f4b71Sopenharmony_ci```
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci![en-us_image_0000001174264366](figures/en-us_image_0000001174264366.png)
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci### Example 3
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci```ts
161e41f4b71Sopenharmony_ci// xxx.ets
162e41f4b71Sopenharmony_ci@Component
163e41f4b71Sopenharmony_cistruct JustifyContentFlex {
164e41f4b71Sopenharmony_ci  justifyContent : number = 0;
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci  build() {
167e41f4b71Sopenharmony_ci    Flex({ justifyContent: this.justifyContent }) {
168e41f4b71Sopenharmony_ci      Text('1').width('20%').height(50).backgroundColor(0xF5DEB3)
169e41f4b71Sopenharmony_ci      Text('2').width('20%').height(50).backgroundColor(0xD2B48C)
170e41f4b71Sopenharmony_ci      Text('3').width('20%').height(50).backgroundColor(0xF5DEB3)
171e41f4b71Sopenharmony_ci    }
172e41f4b71Sopenharmony_ci    .width('90%')
173e41f4b71Sopenharmony_ci    .padding(10)
174e41f4b71Sopenharmony_ci    .backgroundColor(0xAFEEEE)
175e41f4b71Sopenharmony_ci  }
176e41f4b71Sopenharmony_ci}
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci@Entry
179e41f4b71Sopenharmony_ci@Component
180e41f4b71Sopenharmony_cistruct FlexExample3 {
181e41f4b71Sopenharmony_ci  build() {
182e41f4b71Sopenharmony_ci    Column() {
183e41f4b71Sopenharmony_ci      Column({ space: 5 }) {
184e41f4b71Sopenharmony_ci        Text('justifyContent:Start').fontSize(9).fontColor(0xCCCCCC).width('90%')
185e41f4b71Sopenharmony_ci        JustifyContentFlex({ justifyContent: FlexAlign.Start }) // The child components are aligned with the start edge of the main axis.
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci        Text('justifyContent:Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
188e41f4b71Sopenharmony_ci        JustifyContentFlex({ justifyContent: FlexAlign.Center }) // The child components are aligned in the center of the main axis.
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci        Text('justifyContent:End').fontSize(9).fontColor(0xCCCCCC).width('90%')
191e41f4b71Sopenharmony_ci        JustifyContentFlex({ justifyContent: FlexAlign.End }) // The child components are aligned with the end edge of the main axis.
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci        Text('justifyContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%')
194e41f4b71Sopenharmony_ci        JustifyContentFlex({ justifyContent: FlexAlign.SpaceBetween }) // The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end.
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci        Text('justifyContent:SpaceAround').fontSize(9).fontColor(0xCCCCCC).width('90%')
197e41f4b71Sopenharmony_ci        JustifyContentFlex({ justifyContent: FlexAlign.SpaceAround }) // The child components are evenly distributed along the main axis. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci        Text('justifyContent:SpaceEvenly').fontSize(9).fontColor(0xCCCCCC).width('90%')
200e41f4b71Sopenharmony_ci        JustifyContentFlex({ justifyContent: FlexAlign.SpaceEvenly }) // The child components are evenly distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between any two adjacent components are the same.
201e41f4b71Sopenharmony_ci      }.width('100%').margin({ top: 5 })
202e41f4b71Sopenharmony_ci    }.width('100%')
203e41f4b71Sopenharmony_ci  }
204e41f4b71Sopenharmony_ci}
205e41f4b71Sopenharmony_ci```
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci![en-us_image_0000001174582854](figures/en-us_image_0000001174582854.PNG)
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci### Example 4
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci```ts
212e41f4b71Sopenharmony_ci// xxx.ets
213e41f4b71Sopenharmony_ci@Component
214e41f4b71Sopenharmony_cistruct AlignItemsFlex {
215e41f4b71Sopenharmony_ci  alignItems : number = 0;
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci  build() {
218e41f4b71Sopenharmony_ci    Flex({ alignItems: this.alignItems }) {
219e41f4b71Sopenharmony_ci      Text('1').width('33%').height(30).backgroundColor(0xF5DEB3)
220e41f4b71Sopenharmony_ci      Text('2').width('33%').height(40).backgroundColor(0xD2B48C)
221e41f4b71Sopenharmony_ci      Text('3').width('33%').height(50).backgroundColor(0xF5DEB3)
222e41f4b71Sopenharmony_ci    }
223e41f4b71Sopenharmony_ci    .size({width: '90%', height: 80})
224e41f4b71Sopenharmony_ci    .padding(10)
225e41f4b71Sopenharmony_ci    .backgroundColor(0xAFEEEE)
226e41f4b71Sopenharmony_ci  }
227e41f4b71Sopenharmony_ci}
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci@Entry
230e41f4b71Sopenharmony_ci@Component
231e41f4b71Sopenharmony_cistruct FlexExample4 {
232e41f4b71Sopenharmony_ci  build() {
233e41f4b71Sopenharmony_ci    Column() {
234e41f4b71Sopenharmony_ci      Column({ space: 5 }) {
235e41f4b71Sopenharmony_ci        Text('alignItems:Auto').fontSize(9).fontColor(0xCCCCCC).width('90%')
236e41f4b71Sopenharmony_ci        AlignItemsFlex({ alignItems: ItemAlign.Auto }) // The items in the container are aligned with the cross-start edge.
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci        Text('alignItems:Start').fontSize(9).fontColor(0xCCCCCC).width('90%')
239e41f4b71Sopenharmony_ci        AlignItemsFlex({ alignItems: ItemAlign.Start }) // The items in the container are aligned with the cross-start edge.
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci        Text('alignItems:Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
242e41f4b71Sopenharmony_ci        AlignItemsFlex({alignItems: ItemAlign.Center}) // The items in the container are centered along the cross axis.
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci        Text('alignItems:End').fontSize(9).fontColor(0xCCCCCC).width('90%')
245e41f4b71Sopenharmony_ci        AlignItemsFlex({ alignItems: ItemAlign.End }) // The items in the container are aligned with the cross-end edge.
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci        Text('alignItems:Stretch').fontSize(9).fontColor(0xCCCCCC).width('90%')
248e41f4b71Sopenharmony_ci        AlignItemsFlex({ alignItems: ItemAlign.Stretch }) // The items in the container are stretched and padded along the cross axis.
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci        Text('alignItems:Baseline').fontSize(9).fontColor(0xCCCCCC).width('90%')
251e41f4b71Sopenharmony_ci        AlignItemsFlex({ alignItems: ItemAlign.Baseline }) // The items in the container are aligned in such a manner that their text baselines are aligned along the cross axis.
252e41f4b71Sopenharmony_ci      }.width('100%').margin({ top: 5 })
253e41f4b71Sopenharmony_ci    }.width('100%')
254e41f4b71Sopenharmony_ci  }
255e41f4b71Sopenharmony_ci}
256e41f4b71Sopenharmony_ci```
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci![en-us_image_0000001174422904](figures/en-us_image_0000001174422904.png)
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci### Example 5
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci```ts
263e41f4b71Sopenharmony_ci// xxx.ets
264e41f4b71Sopenharmony_ci@Component
265e41f4b71Sopenharmony_cistruct AlignContentFlex {
266e41f4b71Sopenharmony_ci  alignContent: number = 0;
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci  build() {
269e41f4b71Sopenharmony_ci    Flex({ wrap: FlexWrap.Wrap, alignContent: this.alignContent }) {
270e41f4b71Sopenharmony_ci      Text('1').width('50%').height(20).backgroundColor(0xF5DEB3)
271e41f4b71Sopenharmony_ci      Text('2').width('50%').height(20).backgroundColor(0xD2B48C)
272e41f4b71Sopenharmony_ci      Text('3').width('50%').height(20).backgroundColor(0xD2B48C)
273e41f4b71Sopenharmony_ci    }
274e41f4b71Sopenharmony_ci    .size({ width: '90%', height: 90 })
275e41f4b71Sopenharmony_ci    .padding(10)
276e41f4b71Sopenharmony_ci    .backgroundColor(0xAFEEEE)
277e41f4b71Sopenharmony_ci  }
278e41f4b71Sopenharmony_ci}
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci@Entry
281e41f4b71Sopenharmony_ci@Component
282e41f4b71Sopenharmony_cistruct FlexExample5 {
283e41f4b71Sopenharmony_ci  build() {
284e41f4b71Sopenharmony_ci    Column() {
285e41f4b71Sopenharmony_ci      Column({ space: 5 }) {
286e41f4b71Sopenharmony_ci        Text('alignContent:Start').fontSize(9).fontColor(0xCCCCCC).width('90%')
287e41f4b71Sopenharmony_ci        AlignContentFlex({ alignContent: FlexAlign.Start }) // The child components are aligned with the start edge in the multi-row layout.
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci        Text('alignContent:Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
290e41f4b71Sopenharmony_ci        AlignContentFlex({ alignContent: FlexAlign.Center }) // The child components are aligned in the center in the multi-row layout.
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci        Text('alignContent:End').fontSize(9).fontColor(0xCCCCCC).width('90%')
293e41f4b71Sopenharmony_ci        AlignContentFlex({ alignContent: FlexAlign.End }) // The child components are aligned with the end edge in the multi-row layout.
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci        Text('alignContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%')
296e41f4b71Sopenharmony_ci        AlignContentFlex({ alignContent: FlexAlign.SpaceBetween }) // In the multi-row layout, the child component in the first row is aligned with the start edge of the column, and the child component in the last row is aligned with the end edge of the column.
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci        Text('alignContent:SpaceAround').fontSize(9).fontColor(0xCCCCCC).width('90%')
299e41f4b71Sopenharmony_ci        AlignContentFlex({ alignContent: FlexAlign.SpaceAround }) // In the multi-row layout, the space between the child component in the first row and the start edge of the column, and that between the child component in the last row and the end edge of the column are both half the size of the space between two adjacent rows.
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci        Text('alignContent:SpaceEvenly').fontSize(9).fontColor(0xCCCCCC).width('90%')
302e41f4b71Sopenharmony_ci        Flex({
303e41f4b71Sopenharmony_ci          wrap: FlexWrap.Wrap,
304e41f4b71Sopenharmony_ci          alignContent: FlexAlign.SpaceEvenly
305e41f4b71Sopenharmony_ci        }) {// In the multi-row layout, the space between the child component in the first row and the start edge of the column, the space between the child component in the last row and the end edge of the column, and the space between any two adjacent rows are the same.
306e41f4b71Sopenharmony_ci          Text('1').width('50%').height(20).backgroundColor(0xF5DEB3)
307e41f4b71Sopenharmony_ci          Text('2').width('50%').height(20).backgroundColor(0xD2B48C)
308e41f4b71Sopenharmony_ci          Text('3').width('50%').height(20).backgroundColor(0xF5DEB3)
309e41f4b71Sopenharmony_ci          Text('4').width('50%').height(20).backgroundColor(0xD2B48C)
310e41f4b71Sopenharmony_ci          Text('5').width('50%').height(20).backgroundColor(0xF5DEB3)
311e41f4b71Sopenharmony_ci        }
312e41f4b71Sopenharmony_ci        .size({ width: '90%', height: 100 })
313e41f4b71Sopenharmony_ci        .padding({ left: 10, right: 10 })
314e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
315e41f4b71Sopenharmony_ci      }.width('100%').margin({ top: 5 })
316e41f4b71Sopenharmony_ci    }.width('100%')
317e41f4b71Sopenharmony_ci  }
318e41f4b71Sopenharmony_ci}
319e41f4b71Sopenharmony_ci```
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci![en-us_image_0000001174422906](figures/en-us_image_0000001174422906.PNG)
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci### Example 6
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci```ts
326e41f4b71Sopenharmony_ciimport {LengthMetrics} from '@kit.ArkUI';
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci@Entry
329e41f4b71Sopenharmony_ci@Component
330e41f4b71Sopenharmony_cistruct FlexExample2 {
331e41f4b71Sopenharmony_ci  build() {
332e41f4b71Sopenharmony_ci    Column() {
333e41f4b71Sopenharmony_ci      Column({ space: 5 }) {
334e41f4b71Sopenharmony_ci        Text('Wrap').fontSize(9).fontColor(0xCCCCCC).width('90%')
335e41f4b71Sopenharmony_ci        Flex({ wrap: FlexWrap.Wrap, space: {main: LengthMetrics.px(50), cross: LengthMetrics.px(50)} }) { // The child components are arranged in multiple lines.
336e41f4b71Sopenharmony_ci          Text('1').width('40%').height(50).backgroundColor(0xF5DEB3)
337e41f4b71Sopenharmony_ci          Text('2').width('40%').height(50).backgroundColor(0xD2B48C)
338e41f4b71Sopenharmony_ci          Text('3').width('40%').height(50).backgroundColor(0xD2B48C)
339e41f4b71Sopenharmony_ci        }
340e41f4b71Sopenharmony_ci        .width('90%')
341e41f4b71Sopenharmony_ci        .padding(10)
342e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
343e41f4b71Sopenharmony_ci
344e41f4b71Sopenharmony_ci        Text('NoWrap').fontSize(9).fontColor(0xCCCCCC).width('90%')
345e41f4b71Sopenharmony_ci        Flex({ wrap: FlexWrap.Wrap, space: {main: LengthMetrics.px(50), cross: LengthMetrics.px(50)} }) { // The child components are arranged in a single line.
346e41f4b71Sopenharmony_ci          Text('1').width('50%').height(50).backgroundColor(0xF5DEB3)
347e41f4b71Sopenharmony_ci          Text('2').width('50%').height(50).backgroundColor(0xD2B48C)
348e41f4b71Sopenharmony_ci          Text('3').width('50%').height(50).backgroundColor(0xF5DEB3)
349e41f4b71Sopenharmony_ci        }
350e41f4b71Sopenharmony_ci        .width('90%')
351e41f4b71Sopenharmony_ci        .padding(10)
352e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci        Text('WrapReverse').fontSize(9).fontColor(0xCCCCCC).width('90%')
355e41f4b71Sopenharmony_ci        Flex({ wrap: FlexWrap.WrapReverse, direction:FlexDirection.Row, space: {main: LengthMetrics.px(50), cross: LengthMetrics.px(50)} }) { // The child components are reversely arranged in multiple lines.
356e41f4b71Sopenharmony_ci          Text('1').width('40%').height(50).backgroundColor(0xF5DEB3)
357e41f4b71Sopenharmony_ci          Text('2').width('40%').height(50).backgroundColor(0xD2B48C)
358e41f4b71Sopenharmony_ci          Text('3').width('40%').height(50).backgroundColor(0xD2B48C)
359e41f4b71Sopenharmony_ci        }
360e41f4b71Sopenharmony_ci        .width('90%')
361e41f4b71Sopenharmony_ci        .height(120)
362e41f4b71Sopenharmony_ci        .padding(10)
363e41f4b71Sopenharmony_ci        .backgroundColor(0xAFEEEE)
364e41f4b71Sopenharmony_ci      }.width('100%').margin({ top: 5 })
365e41f4b71Sopenharmony_ci    }.width('100%')
366e41f4b71Sopenharmony_ci  }
367e41f4b71Sopenharmony_ci}
368e41f4b71Sopenharmony_ci```
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci![en-us_image_0000001174422907](figures/en-us_image_0000001174422907.PNG)
371