ts-basic-components-divider.md 2.0 KB
Newer Older
Z
zengyawen 已提交
1
# Divider
Z
zengyawen 已提交
2

Z
zengyawen 已提交
3

E
ester.zhou 已提交
4 5
> **NOTE**
>
Z
zengyawen 已提交
6
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
7

Z
zengyawen 已提交
8

9
The **\<Divider>** component is used to separate content blocks and content elements.
Z
zengyawen 已提交
10 11 12


## Required Permissions
Z
zengyawen 已提交
13 14 15

None

Z
zengyawen 已提交
16 17

## Child Components
Z
zengyawen 已提交
18

E
ester.zhou 已提交
19
Not supported
Z
zengyawen 已提交
20

Z
zengyawen 已提交
21 22 23 24 25 26 27 28

## APIs

Divider()


## Attributes

E
esterzhou 已提交
29
| Name | Type | Default Value | Description |
Z
zengyawen 已提交
30
| -------- | -------- | -------- | -------- |
E
esterzhou 已提交
31 32 33 34
| vertical | boolean | false | Whether a vertical divider is used. The value **true** means that a vertical divider is used, and **false** means that a horizontal divider is used. |
| color | Color | - | Color of the divider. |
| strokeWidth | Length | 1 | Width of the divider. |
| lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle-enums) | LineCapStyle.Butt | Cap style of the divider. |
Z
zengyawen 已提交
35 36 37


## Events
Z
zengyawen 已提交
38 39 40

Universal events are not supported.

Z
zengyawen 已提交
41 42 43

## Example

Z
zengyawen 已提交
44

E
ester.zhou 已提交
45 46
```ts
// xxx.ets
Z
zengyawen 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
@Entry
@Component
struct DividerExample {
  build() {
    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
      Text('Horizontal divider').fontSize(9).fontColor(0xCCCCCC)
      Row().width('100%').height(40).backgroundColor(0xF1F3F5)
      Divider()
      Row().width('100%').height(40).backgroundColor(0xF1F3F5)

      Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC)
      Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.Wrap }) {
        Text('bravery')
        Divider().vertical(true).margin(20).height(15)
        Text('effort')
        Divider().vertical(true).margin(20).height(15)
        Text('upward')
      }.width(250)

      Text('Custom Styles').fontSize(9).fontColor(0xCCCCCC)
      Row().width('100%').height(40).backgroundColor(0xF1F3F5)
      Divider().vertical(false).strokeWidth(5).color(0x2788D9).lineCap(LineCapStyle.Round)
      Row().width('100%').height(40).backgroundColor(0xF1F3F5)
    }.width('100%').height(350).padding({ left: 35, right: 35, top: 35 })
  }
}
```

Z
zengyawen 已提交
75
![en-us_image_0000001257058407](figures/en-us_image_0000001257058407.png)