Carousel

Scrolling collections of items whose sizes change as they move through the viewport.

When to use

Multi-browse shows one large item next to medium and small ones, which suits browsing many items. Uncontained keeps every item at one size and lets the last one peek in. Center hero focuses a single item.

Clip each item with maskClip so the item shrinks and grows with the carousel instead of being cut off.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

Multi-browse

Drag or scroll horizontally.

val colors = itemColors()
HorizontalMultiBrowseCarousel(
    state = rememberCarouselState { Titles.size },
    preferredItemWidth = 186.dp,
    itemSpacing = 8.dp,
    modifier = Modifier.fillMaxWidth(),
) { index ->
    CarouselItemBox(Titles[index], colors[index], Modifier.maskClip(MaterialTheme.shapes.extraLarge))
}

Uncontained

val colors = itemColors()
HorizontalUncontainedCarousel(
    state = rememberCarouselState { Titles.size },
    itemWidth = 200.dp,
    itemSpacing = 8.dp,
    modifier = Modifier.fillMaxWidth(),
) { index ->
    CarouselItemBox(Titles[index], colors[index], Modifier.maskClip(MaterialTheme.shapes.extraLarge))
}

Parameters

NameTypeDefaultDescription
stateCarouselStateCreate with rememberCarouselState { itemCount }.
preferredItemWidth / itemWidthDpTarget width of the large item.
itemSpacingDp0.dpGap between items.
contentPaddingPaddingValuesPaddingValues(0.dp)Padding around the carousel content.
content@Composable CarouselItemScope.(Int) -> UnitItem content. Use Modifier.maskClip(shape).

Guidelines

Do:

Don't:

Accessibility

Related components