Compose Component

ImageCard

ImageCard is a version of a card that contains a primary image that is placed at the top of the card.

ImageCardSample

@Sampled
@Composable
fun ImageCardSample() {
    ImageCard(
        image = { Image(MyImage, "Localized description", contentScale = ContentScale.FillWidth) }
    ) {
        Text("This is an image card")
    }
}

ImageCardWithTitleAndSubtitleAndLeadingIconSample

@Sampled
@Composable
fun ImageCardWithTitleAndSubtitleAndLeadingIconSample() {
    ImageCard(
        image = { Image(MyImage, "Localized description", contentScale = ContentScale.FillWidth) },
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text("This is an image card with a title, subtitle, and leading icon")
    }
}

NonFocusableCardWithButtonGroupSample

@Sampled
@Composable
fun NonFocusableCardWithButtonGroupSample() {
    Column(verticalArrangement = Arrangement.spacedBy(GlimmerTheme.componentSpacingValues.large)) {
        Card(focusable = false) { Text("This is a non-focusable card with a button group") }
        ButtonGroup(modifier = Modifier.fillMaxWidth()) {
            Button(onClick = {}) { Text("Button 1") }
            Button(onClick = {}) { Text("Button 2") }
            Button(onClick = {}) { Text("Button 3") }
        }
    }
}

// -------------------------------------------------------------------------------------------------
// ActionCard samples
// -------------------------------------------------------------------------------------------------

ClickableImageCardSample

@Sampled
@Composable
fun ClickableImageCardSample() {
    ImageCard(
        onClick = {},
        image = { Image(MyImage, "Localized description", contentScale = ContentScale.FillWidth) },
    ) {
        Text("This is an image card")
    }
}

ClickableImageCardWithTitleAndSubtitleAndLeadingIconSample

@Sampled
@Composable
fun ClickableImageCardWithTitleAndSubtitleAndLeadingIconSample() {
    ImageCard(
        onClick = {},
        image = { Image(MyImage, "Localized description", contentScale = ContentScale.FillWidth) },
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text("This is an image card with a title, subtitle, and leading icon")
    }
}

// -------------------------------------------------------------------------------------------------
// Leading/Trailing ImageCard samples
// -------------------------------------------------------------------------------------------------
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: