The ArcScrollBar component is designed to be used together with scrollable components such as ArcList, List, Grid, Scroll, and WaterFlow.
ArcScrollBar(options: ArcScrollBarOptions)
A constructor used to create an ArcScrollBar instance.
Atomic service API: This API can be used in atomic services since API version 18.
System capability: SystemCapability.ArkUI.ArkUI.Circle
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | ArcScrollBarOptions | Yes | Parameters of the ArcScrollBar component. |
Represents the parameters used to construct an ArcScrollBar component.
Atomic service API: This API can be used in atomic services since API version 18.
System capability: SystemCapability.ArkUI.ArkUI.Circle
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| scroller | Scroller | No | No | Scroller, which can be bound to scrollable components for scrolling control. |
| state | BarState | No | Yes | State of the scrollbar. Default value: BarState.Auto |
ArcScrollBar must be bound to a scrollable component through scroller to achieve synchronization. Only a one-to-one binding is allowed between ArcScrollBar and a scrollable component.
This example demonstrates how to synchronize ArcScrollBar with the Scroll component to implement an arc scrollbar.
import { ArcScrollBar } from '@kit.ArkUI';
@Entry
@Component
struct ArcScrollBarExample {
private scroller: Scroller = new Scroller();
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
build() {
Stack({ alignContent: Alignment.Center }) {
Scroll(this.scroller) {
Flex({ direction: FlexDirection.Column }) {
ForEach(this.arr, (item: number) => {
Row() {
Text(item.toString())
.width('80%')
.height(60)
.backgroundColor('#3366CC')
.borderRadius(15)
.fontSize(16)
.textAlign(TextAlign.Center)
.margin({ top: 5 })
}
}, (item: number) => item.toString())
}.margin({ right: 15 })
}
.width('90%')
.scrollBar(BarState.Off)
ArcScrollBar({ scroller: this.scroller, state: BarState.Auto })
}
.width('100%')
.height('100%')
}
} 