CustomCarousel

fun <T> CustomCarousel(items: List<T>, sidePadding: Dp, shapeSize: Dp = SizeConstants.MediumSize, pagerState: PagerState, itemContent: @Composable (item: T) -> Unit)(source)

Displays a horizontally swipeable carousel with a synchronized animated dot indicator.

State ownership:

Guardrails:

  • Keep items stable across recompositions for predictable paging and animation behavior.

  • Provide a pagerState whose page count matches items to avoid invalid page access.

  • Use non-negative sidePadding so content remains readable.

Example:

val items = remember { listOf("One", "Two", "Three") }
val pagerState = rememberPagerState(pageCount = { items.size })
CustomCarousel(
items = items,
sidePadding = 16.dp,
pagerState = pagerState,
) { item ->
Text(text = item)
}

Parameters

items

Ordered list of models rendered page-by-page.

sidePadding

Horizontal inset applied on both sides of the pager content.

pagerState

Shared pager state that controls and reports current page selection.

itemContent

Composable renderer for each carousel item.