1# Divider 2 3The **\<Divider>** component is used to separate content blocks and elements. 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 12Not supported 13 14 15## APIs 16 17Divider() 18 19Since API version 9, this API is supported in ArkTS widgets. 20 21## Attributes 22 23In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. 24 25| Name | Type | Description | 26| ----------- | ---------- | ------------------ | 27| vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.<br>**true**: A vertical divider is used.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| 28| color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.<br>Default value: **'\#33182431'**<br>Since API version 9, this API is supported in ArkTS widgets.| 29| strokeWidth | number \| string | Width of the divider.<br>Default value: **1**<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute cannot be set to a percentage. The priority of this attribute is lower than that of the universal attribute [height](ts-universal-attributes-size.md). If the value of this attribute is greater than that of the universal attribute, cropping is performed based on the universal attribute settings.| 30| lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.| 31 32 33## Example 34 35```ts 36// xxx.ets 37@Entry 38@Component 39struct DividerExample { 40 build() { 41 Column() { 42 // Use horizontal dividers. 43 Text('Horizontal divider').fontSize(9).fontColor(0xCCCCCC) 44 List() { 45 ForEach([1, 2, 3], (item) => { 46 ListItem() { 47 Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start) 48 }.width(244).height(48) 49 }, item => item.toString()) 50 }.padding({ left: 24, bottom: 8 }) 51 52 Divider().strokeWidth(8).color('#F1F3F5') 53 List() { 54 ForEach([4, 5], (item) => { 55 ListItem() { 56 Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start) 57 }.width(244).height(48) 58 }, item => item.toString()) 59 }.padding({ left: 24, top: 8 }) 60 61 // Use vertical dividers. 62 Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC) 63 Column() { 64 Column() { 65 Row().width(288).height(64).backgroundColor('#30C9F0').opacity(0.3) 66 Row() { 67 Button('Button') 68 .width(136) 69 .height(22) 70 .fontSize(16) 71 .fontColor('#007DFF') 72 .fontWeight(500) 73 .backgroundColor(Color.Transparent) 74 Divider().vertical(true).height(22).color('#182431').opacity(0.6).margin({ left: 8, right: 8 }) 75 Button('Button') 76 .width(136) 77 .height(22) 78 .fontSize(16) 79 .fontColor('#007DFF') 80 .fontWeight(500) 81 .backgroundColor(Color.Transparent) 82 }.margin({ top: 17 }) 83 } 84 .width(336) 85 .height(152) 86 .backgroundColor('#FFFFFF') 87 .borderRadius(24) 88 .padding(24) 89 } 90 .width('100%') 91 .height(168) 92 .backgroundColor('#F1F3F5') 93 .justifyContent(FlexAlign.Center) 94 .margin({ top: 8 }) 95 }.width('100%').padding({ top: 24 }) 96 } 97} 98``` 99 100 101