Stay organized with collections
Save and categorize content based on your preferences.
Using page indicators, you can help your users understand their current position
within your app's content, providing a visual indication of progress. These
navigational cues are useful when you present content sequentially, such as
carousel implementations, image galleries and slideshows, or pagination in
lists.
Version compatibility
This implementation requires that your project minSDK be set to API level 21 or
higher.
Dependencies
Create a horizontal pager with a custom page indicator
The following code creates a horizontal pager that has a page indicator, giving
the user visual cues for how many pages there are and which page is
visible:
The code implements a HorizontalPager, which lets you swipe
horizontally between different pages of content. In this case, each page
displays the page number.
The rememberPagerState() function initializes the pager and sets the
number of pages to 4. This function creates a state object that tracks the
current page, and lets you control the pager.
The pagerState.currentPage property is used to determine which page
indicator should be highlighted.
The page indictator appears in a pager overlaid by a Row
implementation.
A 16 dp circle is drawn for each page in the pager. The indicator for the
current page is displayed as DarkGray, while the rest of the indicator
circles are LightGray.
The Text composable within the HorizontalPager displays the text
"Page: [page number]" on each page.
Results
Figure 1. Pager showing a circle indicator under the content.
Collections that contain this guide
This guide is part of these curated Quick Guide collections that cover
broader Android development goals:
Display a list or grid
Lists and grids allow your app to display collections in a
visually pleasing form that's easy for users to consume.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-09-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[],[],null,["\u003cbr /\u003e\n\nUsing page indicators, you can help your users understand their current position\nwithin your app's content, providing a visual indication of progress. These\nnavigational cues are useful when you present content sequentially, such as\ncarousel implementations, image galleries and slideshows, or pagination in\nlists.\n\nVersion compatibility\n\nThis implementation requires that your project minSDK be set to API level 21 or\nhigher.\n\nDependencies\n\nCreate a horizontal pager with a custom page indicator\n\nThe following code creates a horizontal pager that has a page indicator, giving\nthe user visual cues for how many pages there are and which page is\nvisible:\n\n\n```kotlin\nval pagerState = rememberPagerState(pageCount = {\n 4\n})\nHorizontalPager(\n state = pagerState,\n modifier = Modifier.fillMaxSize()\n) { page -\u003e\n // Our page content\n Text(\n text = \"Page: $page\",\n )\n}\nRow(\n Modifier\n .wrapContentHeight()\n .fillMaxWidth()\n .align(Alignment.BottomCenter)\n .padding(bottom = 8.dp),\n horizontalArrangement = Arrangement.Center\n) {\n repeat(pagerState.pageCount) { iteration -\u003e\n val color = if (pagerState.currentPage == iteration) Color.DarkGray else Color.LightGray\n Box(\n modifier = Modifier\n .padding(2.dp)\n .clip(CircleShape)\n .background(color)\n .size(16.dp)\n )\n }\n}https://github.com/android/snippets/blob/3d5181b4813a17a1c236b134cc207dfee625885c/compose/snippets/src/main/java/com/example/compose/snippets/layouts/PagerSnippets.kt#L381-L411\n```\n\n\u003cbr /\u003e\n\nKey points about the code\n\n- The code implements a [`HorizontalPager`](/reference/kotlin/androidx/compose/foundation/pager/package-summary#HorizontalPager(androidx.compose.foundation.pager.PagerState,androidx.compose.ui.Modifier,androidx.compose.foundation.layout.PaddingValues,androidx.compose.foundation.pager.PageSize,kotlin.Int,androidx.compose.ui.unit.Dp,androidx.compose.ui.Alignment.Vertical,androidx.compose.foundation.gestures.TargetedFlingBehavior,kotlin.Boolean,kotlin.Boolean,kotlin.Function1,androidx.compose.ui.input.nestedscroll.NestedScrollConnection,androidx.compose.foundation.gestures.snapping.SnapPosition,kotlin.Function2)), which lets you swipe horizontally between different pages of content. In this case, each page displays the page number.\n- The `rememberPagerState()` function initializes the pager and sets the number of pages to 4. This function creates a state object that tracks the current page, and lets you control the pager.\n- The [`pagerState.currentPage`](/reference/kotlin/androidx/compose/foundation/pager/PagerState#currentPage()) property is used to determine which page indicator should be highlighted.\n- The page indictator appears in a pager overlaid by a [`Row`](/reference/kotlin/androidx/compose/foundation/layout/package-summary#Row(androidx.compose.ui.Modifier,androidx.compose.foundation.layout.Arrangement.Horizontal,androidx.compose.ui.Alignment.Vertical,kotlin.Function1)) implementation.\n- A 16 dp circle is drawn for each page in the pager. The indicator for the current page is displayed as `DarkGray`, while the rest of the indicator circles are `LightGray`.\n- The [`Text`](/reference/kotlin/androidx/compose/material/package-summary#Text(androidx.compose.ui.text.AnnotatedString,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontFamily,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.style.TextDecoration,androidx.compose.ui.text.style.TextAlign,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.style.TextOverflow,kotlin.Boolean,kotlin.Int,kotlin.Int,kotlin.collections.Map,kotlin.Function1,androidx.compose.ui.text.TextStyle)) composable within the `HorizontalPager` displays the text \"Page: \\[page number\\]\" on each page.\n\nResults **Figure 1.** Pager showing a circle indicator under the content.\n\nCollections that contain this guide\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\nDisplay a list or grid \nLists and grids allow your app to display collections in a visually pleasing form that's easy for users to consume. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-a-list-or-grid) \n\nDisplay interactive components \nLearn how composable functions can enable you to easily create beautiful UI components based on the Material Design design system. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-interactive-components) \n\nHave questions or feedback \nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]