Skip to content
Lists & Grids

Pager

Swipeable pages with a state-driven page count

HorizontalPager lays out swipeable pages backed by a PagerState. The state exposes currentPage, which can drive indicator dots beneath the pager.

Pager demos rendered in Compose Playground
Pixel-accurate preview · light theme

Examples

01

Horizontal pager with dots

Four swipeable pages with indicator dots reflecting the current page.

Kotlin
val state = rememberPagerState(pageCount = { 4 })
HorizontalPager(state = state, modifier = Modifier.height(180.dp)) { page ->
    Box(contentAlignment = Alignment.Center) {
        Text("${page + 1}", style = MaterialTheme.typography.displayLarge)
    }
}
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
    repeat(4) { index ->
        val active = state.currentPage == index
        Box(
            modifier = Modifier
                .size(if (active) 10.dp else 8.dp)
                .clip(CircleShape)
                .background(if (active) selected else unselected)
        )
    }
}