• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Row
2
3The **<Row\>** component lays out child components horizontally.
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
17Row(value?:{space?:  number | string })
18
19Since API version 9, this API is supported in ArkTS widgets.
20
21**Parameters**
22
23| Name| Type| Mandatory| Description|
24| -------- | -------- | -------- | -------- |
25| space | string \| number | No| Horizontal 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 **justifyContent** is set to **FlexAlign.SpaceBetween**, **FlexAlign.SpaceAround** or **FlexAlign.SpaceEvenly**.<br>Default value: **0**, in 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.|
26
27
28## Attributes
29
30| Name| Type| Description|
31| -------- | -------- | -------- |
32| alignItems | [VerticalAlign](ts-appendix-enums.md#verticalalign) | Alignment mode of child components in the vertical direction.<br>Default value: **VerticalAlign.Center**<br>Since API version 9, this API is supported in ArkTS widgets.|
33| justifyContent<sup>8+</sup> | [FlexAlign](ts-appendix-enums.md#flexalign) | Alignment mode of the child components in the horizontal direction.<br>FlexAlign.Start <br>Since API version 9, this API is supported in ArkTS widgets.|
34
35
36## Example
37
38```ts
39// xxx.ets
40@Entry
41@Component
42struct RowExample {
43  build() {
44    Column({ space: 5 }) {
45      // Set the horizontal spacing between two adjacent child components to 5.
46      Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%')
47      Row({ space: 5 }) {
48        Row().width('30%').height(50).backgroundColor(0xAFEEEE)
49        Row().width('30%').height(50).backgroundColor(0x00FFFF)
50      }.width('90%').height(107).border({ width: 1 })
51
52      // Set the alignment mode of the child components in the vertical direction.
53      Text('alignItems(Bottom)').fontSize(9).fontColor(0xCCCCCC).width('90%')
54      Row() {
55        Row().width('30%').height(50).backgroundColor(0xAFEEEE)
56        Row().width('30%').height(50).backgroundColor(0x00FFFF)
57      }.width('90%').alignItems(VerticalAlign.Bottom).height('15%').border({ width: 1 })
58
59      Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%')
60      Row() {
61        Row().width('30%').height(50).backgroundColor(0xAFEEEE)
62        Row().width('30%').height(50).backgroundColor(0x00FFFF)
63      }.width('90%').alignItems(VerticalAlign.Center).height('15%').border({ width: 1 })
64
65      // Set the alignment mode of the child components in the horizontal direction.
66      Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%')
67      Row() {
68        Row().width('30%').height(50).backgroundColor(0xAFEEEE)
69        Row().width('30%').height(50).backgroundColor(0x00FFFF)
70      }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.End)
71
72      Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%')
73      Row() {
74        Row().width('30%').height(50).backgroundColor(0xAFEEEE)
75        Row().width('30%').height(50).backgroundColor(0x00FFFF)
76      }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.Center)
77    }.width('100%')
78  }
79}
80```
81
82![row](figures/row.png)
83