UX4G Logo
Components

Carousel

Horizontal paging banner carousel with auto-play, animated pill dot indicators, navigation arrows, hero gradient slides, and image gallery overlays

The UX4G Carousel suite provides production-ready horizontal paging banners with smooth spring animations, auto-play timers, and animated dot/capsule pagination:

  1. Hero Banner Carousel (Ux4gHeroCarouselSlide): Vibrant multi-color gradient slide with category badge, bold headline, description, and white action button.
  2. Image Gallery Carousel (Ux4gImageCarouselSlide): Full-bleed photo slide with dark gradient overlay, category tag, headline, and subtitle.
  3. Custom Content Carousel: Dynamic carousel accepting any custom composable slide builder with configurable heights and page transitions.

Import from com.ux4g.designsystemv1.components.Ux4gCarousel.


Interactive Previews

Ux4gCarousel - Hero Gradient BannersJetpack Compose
UX4G Carousel Hero Banner Preview

Ux4gCarousel - Image Gallery with Dark OverlayJetpack Compose
UX4G Carousel Image Gallery Preview

Kotlin Usage

Carousel Showcase Example
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.Ux4gCarousel
import com.ux4g.designsystemv1.components.Ux4gHeroCarouselSlide
import com.ux4g.designsystemv1.components.Ux4gImageCarouselSlide

@Composable
fun CarouselShowcaseScreen() {
    Column(
        modifier = Modifier
            .fillMaxWidth()
            .padding(16.dp),
        verticalArrangement = Arrangement.spacedBy(24.dp)
    ) {
        // 1. Hero Gradient Banners Carousel
        Ux4gCarousel(
            height = 240.dp,
            autoPlay = true,
            autoPlayIntervalMs = 3000L,
            showPagination = true,
            showPaginationArrows = true,
            items = listOf(
                {
                    Ux4gHeroCarouselSlide(
                        gradientColors = listOf(Color(0xFFD97706), Color(0xFFE11D48)),
                        badgeText = "POPULAR",
                        title = "Unified Design System",
                        description = "Production-ready accessible UI components built for digital infrastructure.",
                        buttonText = "Get Started",
                        onButtonClick = { /* handle action */ }
                    )
                },
                {
                    Ux4gHeroCarouselSlide(
                        gradientColors = listOf(Color(0xFF4F46E5), Color(0xFF7C3AED)),
                        badgeText = "FEATURED",
                        title = "Digital Services Portal 2.0",
                        description = "Seamlessly access government citizen services with single sign-on and instant verification.",
                        buttonText = "Explore Services",
                        onButtonClick = { /* handle action */ }
                    )
                }
            )
        )

        // 2. Image Gallery Overlay Carousel
        Ux4gCarousel(
            height = 240.dp,
            autoPlay = false,
            items = listOf(
                {
                    Ux4gImageCarouselSlide(
                        imageUrl = "https://images.unsplash.com/photo-1451187580459-43490279c0fa?auto=format&fit=crop&w=800&q=80",
                        badgeText = "NETWORK",
                        title = "Global Cloud Infrastructure",
                        subtitle = "High availability and low latency cross-region deployment."
                    )
                },
                {
                    Ux4gImageCarouselSlide(
                        imageUrl = "https://images.unsplash.com/photo-1579546929518-9e396f3cc809?auto=format&fit=crop&w=800&q=80",
                        badgeText = "DESIGN",
                        title = "Modern UI System Architecture",
                        subtitle = "Crafted with accessible design tokens & fluid responsive components."
                    )
                }
            )
        )
    }
}

Parameters

1. Ux4gCarousel Props

PropTypeDescriptionDefault
items *List<@Composable () -> Unit>List of composable slide items to render.—
modifierModifierCompose layout modifier applied to the carousel root container.Modifier
autoPlayBooleanWhether the carousel automatically cycles through slide pages.true
autoPlayIntervalMsLongTime in milliseconds between automatic slide transitions.3000L
showPaginationBooleanWhether to display the dot pagination indicator at the bottom.true
showPaginationArrowsBooleanWhether to show left/right arrow buttons alongside pagination dots.true
heightDpFixed height of the carousel container.240.dp
viewportFractionFloatFraction of the viewport each page should occupy (1.0f for full width).1.0f
contentPaddingPaddingValuesInner padding surrounding pages in viewport.PaddingValues(0.dp)
pageSpacingDpSpacing between consecutive slide pages.0.dp
activePaginationColorColorFill color for the active elongated pill indicator.Ux4gColors.primary
inactivePaginationColorColorFill color for inactive dot indicators.Ux4gColors.primary100
paginationArrowBackgroundColorColorCircular background color for previous/next arrow buttons.Color(0xFFDCD6FD)
paginationArrowColorColorIcon tint color for navigation arrow chevrons.Ux4gColors.primary
paginationVariantUx4gPaginationVariantVisual container style: Default (transparent) or Capsule (white pill).Ux4gPaginationVariant.Default
paginationSizeUx4gPaginationSizeSizing preset: Small or Medium.Ux4gPaginationSize.Small
onPageChange((Int) -> Unit)?Callback triggered whenever the current active page index changes.null

2. Ux4gHeroCarouselSlide Props

PropTypeDescriptionDefault
gradientColors *List<Color>Linear gradient color stops applied to background banner.—
badgeText *StringText displayed in top semi-transparent category badge.—
title *StringLarge headline text inside the banner.—
description *StringParagraph description text.—
buttonText *StringLabel for the white filled call-to-action button.—
modifierModifierCompose layout modifier.Modifier
borderRadiusDpCorner rounding radius for slide boundary.16.dp
onButtonClick() -> UnitClick listener callback for the action button.{}

3. Ux4gImageCarouselSlide Props

PropTypeDescriptionDefault
imageUrl *StringRemote URL or image asset path loaded via Coil.—
badgeText *StringText displayed inside the top-left dark tag badge.—
title *StringHeadline text overlaid on dark bottom gradient.—
subtitle *StringSubtitle description text.—
modifierModifierCompose layout modifier.Modifier
borderRadiusDpCorner rounding radius.16.dp

On this page