The border attributes are used to set border styles for components.
The initial APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
border(value: BorderOptions): T
Sets the border.
Widget capability: This API can be used in ArkTS widgets since API version 9.
Atomic service API: This API can be used in atomic services since API version 11.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| value | BorderOptions | Yes | Unified border style. NOTE The default value is 0, indicating that no border is displayed. Since API version 9, the parent node's border is displayed above child node content. |
Return value
| Type | Description |
|---|---|
| T | Current component. |
When neither color nor radius is specified, set borderColor and borderRadius after border to ensure they take effect.
borderStyle(value: BorderStyle | EdgeStyles): T
Sets the border style.
Widget capability: This API can be used in ArkTS widgets since API version 9.
Atomic service API: This API can be used in atomic services since API version 11.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| value | BorderStyle | EdgeStyles9+ | Yes | Border style. Default value: BorderStyle.Solid |
Return value
| Type | Description |
|---|---|
| T | Current component. |
borderWidth(value: Length | EdgeWidths | LocalizedEdgeWidths): T
Sets the border width.
Widget capability: This API can be used in ArkTS widgets since API version 9.
Atomic service API: This API can be used in atomic services since API version 11.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| value | Length | EdgeWidths9+ | LocalizedEdgeWidths12+ | Yes | Border width. This parameter cannot be set in percentage. |
Return value
| Type | Description |
|---|---|
| T | Current component. |
borderColor(value: ResourceColor | EdgeColors | LocalizedEdgeColors): T
Sets the border color.
Widget capability: This API can be used in ArkTS widgets since API version 9.
Atomic service API: This API can be used in atomic services since API version 11.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| value | ResourceColor | EdgeColors9+ | LocalizedEdgeColors12+ | Yes | Border color. Default value: Color.Black |
Return value
| Type | Description |
|---|---|
| T | Current component. |
borderRadius(value: Length | BorderRadiuses | LocalizedBorderRadiuses): T
Sets the border radius.
Widget capability: This API can be used in ArkTS widgets since API version 9.
Atomic service API: This API can be used in atomic services since API version 11.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| value | Length | BorderRadiuses9+ | LocalizedBorderRadiuses12+ | Yes | Radius of the border corners. The value can be expressed as a percentage of the component's width. When combined with the clip attribute, this setting clips child components to prevent them from extending beyond the component's boundaries. |
Return value
| Type | Description |
|---|---|
| T | Current component. |
borderRadius(value: Length | BorderRadiuses | LocalizedBorderRadiuses, type?: RenderStrategy): T
Sets the border corner radius and the rendering strategy for rounded corners.
Widget capability: This API can be used in ArkTS widgets since API version 22.
Atomic service API: This API can be used in atomic services since API version 22.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| value | Length | BorderRadiuses | LocalizedBorderRadiuses | Yes | Radius of the border corners. The value can be expressed as a percentage of the component's width. When combined with the clip attribute, this setting clips child components to prevent them from extending beyond the component's boundaries. |
| type | RenderStrategy | No | Rendering strategy for drawing rounded corners. Default value: RenderStrategy.FAST. |
Return value
| Type | Description |
|---|---|
| T | Current component. |
This example shows how to set the border width, color, border radius, and styles such as dotted or dashed lines.
// xxx.ets
@Entry
@Component
struct BorderExample {
build() {
Column() {
Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) {
// Dashed border
Text('dashed')
.borderStyle(BorderStyle.Dashed)
.borderWidth(5)
.borderColor(0xAFEEEE)
.borderRadius(10)
.width(120)
.height(120)
.textAlign(TextAlign.Center)
.fontSize(16)
// Dotted border
Text('dotted')
.border({
width: 5,
color: 0x317AF7,
radius: 10,
style: BorderStyle.Dotted
})
.width(120)
.height(120)
.textAlign(TextAlign.Center)
.fontSize(16)
}.width('100%').height(150)
Text('.border')
.fontSize(50)
.width(300)
.height(300)
.border({
width: {
left: 3,
right: 6,
top: 10,
bottom: 15
},
color: {
left: '#e3bbbb',
right: Color.Blue,
top: Color.Red,
bottom: Color.Green
},
radius: {
topLeft: 10,
topRight: 20,
bottomLeft: 40,
bottomRight: 80
},
style: {
left: BorderStyle.Dotted,
right: BorderStyle.Dotted,
top: BorderStyle.Solid,
bottom: BorderStyle.Dashed
}
})
.textAlign(TextAlign.Center)
}
}
} 
In this example, the width, radius, and color properties of the border attribute use the LocalizedEdgeWidths and LocalizedEdgeColors types.
// xxx.ets
import { LengthMetrics } from '@kit.ArkUI';
@Entry
@Component
struct BorderExample {
build() {
Column() {
Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) {
// Dashed border
Text('dashed')
.borderStyle(BorderStyle.Dashed)
.borderWidth(5)
.borderColor(0xAFEEEE)
.borderRadius(10)
.width(120)
.height(120)
.textAlign(TextAlign.Center)
.fontSize(16)
// Dotted border
Text('dotted')
.border({
width: 5,
color: 0x317AF7,
radius: 10,
style: BorderStyle.Dotted
})
.width(120)
.height(120)
.textAlign(TextAlign.Center)
.fontSize(16)
}.width('100%').height(150)
Text('.border')
.fontSize(50)
.width(300)
.height(300)
.border({
width: {
start: LengthMetrics.vp(3),
end: LengthMetrics.vp(6),
top: LengthMetrics.vp(10),
bottom: LengthMetrics.vp(15)
},
color: {
start: '#e3bbbb',
end: Color.Blue,
top: Color.Red,
bottom: Color.Green
},
radius: {
topStart: LengthMetrics.vp(10),
topEnd: LengthMetrics.vp(20),
bottomStart: LengthMetrics.vp(40),
bottomEnd: LengthMetrics.vp(80)
},
style: {
left: BorderStyle.Dotted,
right: BorderStyle.Dotted,
top: BorderStyle.Solid,
bottom: BorderStyle.Dashed
}
})
.textAlign(TextAlign.Center)
}
}
} The following shows how the example is represented with left-to-right scripts.

The following shows how the example is represented with right-to-left scripts.

This example demonstrates how to set the rendering strategy for drawing rounded corners on components, supported since API version 22.
// xxx.ets
@Entry
@Component
struct RenderStrategyExample {
build() {
NavDestination() {
Column({ space: 20 }) {
Stack() {
Column()
.width(320)
.height(320)
.backgroundColor(Color.Black)
Stack() {
Stack() {
Scroll(new Scroller()) {
Image($r('app.media.startIcon'))
.width('100%')
.height('200%')
}
Column()
.blur(50)
.width(300)
.height(100)
.position({ x: 0, y: 0 })
}
}
.width(300)
.height(300)
.backgroundColor(Color.Pink)
.borderRadius(50, RenderStrategy.FAST)
.clip(true)
}
Stack() {
Column()
.width(320)
.height(320)
.backgroundColor(Color.Black)
Stack() {
Stack() {
Scroll(new Scroller()) {
Image($r('app.media.startIcon'))
.width('100%')
.height('200%')
}
Column()
.blur(50)
.width(300)
.height(100)
.position({ x: 0, y: 0 })
}
}
.width(300)
.height(300)
.backgroundColor(Color.Pink)
.borderRadius(50, RenderStrategy.OFFSCREEN)
.clip(true)
}
}
}
.width('100%')
.height('100%')
}
} The following illustration compares online rendering (top) with offscreen rendering (bottom) modes.
