AospPageIndicator

fun AospPageIndicator(pagerState: PagerState, modifier: Modifier = Modifier, dotSize: Dp = 6.4.dp, dotSpacing: Dp = 3.2.dp, maxVisibleDots: Int = 7, selectedColor: Color = MaterialTheme.colorScheme.primary, unselectedColor: Color = selectedColor.copy( alpha = selectedColor.alpha * AOSP_INACTIVE_ALPHA ), pageDescription: String? = null)(source)

An Android 10 Quick Settings-inspired page indicator that tracks a PagerState continuously.

Unlike the original SystemUI implementation, this indicator reads the pager's continuous scroll offset during the draw phase instead of maintaining a pending-transition queue, preventing stale target desynchronization under rapid swipes or button jumps.

State ownership:

  • Callers own pagerState, sizing, colors, and pageDescription.

  • Nothing is rendered when pagerState.pageCount <= 1.

  • For page counts above maxVisibleDots, the visible dots form a continuous sliding window.

Parameters

pagerState

Shared pager state providing pageCount, currentPage, and currentPageOffsetFraction.

modifier

Modifier applied to the indicator canvas.

dotSize

Diameter of each circular dot (> 0.dp).

dotSpacing

Horizontal gap between adjacent dots (>= 0.dp).

maxVisibleDots

Maximum number of dots visible at once before sliding-window scrolling begins (>= 2).

selectedColor

Fill color of the active capsule.

unselectedColor

Fill color of inactive dots, defaulting to 42% of selectedColor's alpha.

pageDescription

Optional localized accessibility state description overriding the default English label.


fun AospPageIndicator(pageCount: Int, selectedIndex: Int, modifier: Modifier = Modifier, dotSize: Dp = 6.4.dp, dotSpacing: Dp = 3.2.dp, maxVisibleDots: Int = 7, animationDurationMillis: Int = AOSP_ANIMATION_DURATION, selectedColor: Color = MaterialTheme.colorScheme.primary, unselectedColor: Color = selectedColor.copy( alpha = selectedColor.alpha * AOSP_INACTIVE_ALPHA ), pageDescription: String? = null)(source)

An Android 10 Quick Settings-inspired page indicator for components that manage an integer selectedIndex rather than a PagerState.

State ownership:

Parameters

pageCount

Total number of pages. Nothing is rendered when pageCount <= 1.

selectedIndex

Zero-based active page index, clamped to 0 until pageCount.

modifier

Modifier applied to the indicator canvas.

dotSize

Diameter of each circular dot (> 0.dp).

dotSpacing

Horizontal gap between adjacent dots (>= 0.dp).

maxVisibleDots

Maximum number of dots visible at once before sliding-window scrolling begins (>= 2).

animationDurationMillis

Duration in milliseconds for single-step page transitions (>= 0).

selectedColor

Fill color of the active capsule.

unselectedColor

Fill color of inactive dots, defaulting to 42% of selectedColor's alpha.

pageDescription

Optional localized accessibility state description overriding the default English label.