androidx.compose.material3

Card

Composable function

A card groups content about one subject, like a message, a photo or a setting.

A basic card
A basic card
Card(modifier = Modifier.width(280.dp)) {
    Column(Modifier.padding(16.dp)) {
        Text("Trip to Lisbon", style = MaterialTheme.typography.titleMedium)
        Text("3 nights · 12–15 May", style = MaterialTheme.typography.bodyMedium)
    }
}

There are three card types. They differ only in color, shadow and outline. See Card types.

The three card types
The three card types
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
    Card(Modifier.width(140.dp)) { Text("Filled", Modifier.padding(16.dp)) }
    ElevatedCard(Modifier.width(140.dp)) { Text("Elevated", Modifier.padding(16.dp)) }
    OutlinedCard(Modifier.width(140.dp)) { Text("Outlined", Modifier.padding(16.dp)) }
}

Basic

Not clickable. Use it to group content.

@Composable
fun Card(
    modifier: Modifier = Modifier,
    shape: Shape = CardDefaults.shape,
    colors: CardColors = CardDefaults.cardColors(),
    elevation: CardElevation = CardDefaults.cardElevation(),
    border: BorderStroke? = null,
    content: @Composable ColumnScope.() -> Unit,
)

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position of the card. See the Modifier guide. A card is as wide as its content by default. Use Modifier.fillMaxWidth() to stretch it.

shape: ShapeOptional

Default: CardDefaults.shape

Sets the outline of the card. Default: the theme's medium shape (12 dp corners). See the Shapes guide.

Larger corners from the theme
Larger corners from the theme
Card(shape = MaterialTheme.shapes.extraLarge, modifier = Modifier.width(280.dp)) {
    Text("28 dp corners", Modifier.padding(24.dp))
}

colors: CardColorsOptional

Default: CardDefaults.cardColors()

Sets the background and content colors. Make one with CardDefaults.cardColors. Each card type has its own function.

Tertiary container colors
Tertiary container colors
Card(
    colors = CardDefaults.cardColors(
        containerColor = MaterialTheme.colorScheme.tertiaryContainer,
        contentColor = MaterialTheme.colorScheme.onTertiaryContainer,
    ),
    modifier = Modifier.width(280.dp),
) {
    Text("Tip: drag to reorder", Modifier.padding(16.dp))
}

elevation: CardElevationOptional

Default: CardDefaults.cardElevation()

Sets the shadow height, also while pressed or dragged. Make one with CardDefaults.cardElevation.

More shadow
More shadow
ElevatedCard(
    elevation = CardDefaults.elevatedCardElevation(defaultElevation = 8.dp),
    modifier = Modifier.width(280.dp),
) {
    Text("Raised card", Modifier.padding(16.dp))
}

border: BorderStroke?Optional

Default: null

Draws an outline. null means no outline. OutlinedCard has one by default.

A colored outline
A colored outline
Card(
    border = BorderStroke(2.dp, MaterialTheme.colorScheme.primary),
    modifier = Modifier.width(280.dp),
) {
    Text("Selected plan", Modifier.padding(16.dp))
}

content: @Composable ColumnScope.() -> UnitRequired

What the card shows. Items are placed in a Column, top to bottom. The card adds no padding. Add it yourself, usually 16 dp.

Text and actions
Text and actions
OutlinedCard(Modifier.width(280.dp)) {
    Column(Modifier.padding(16.dp)) {
        Text("Delete file?", style = MaterialTheme.typography.titleMedium)
        Text("This can't be undone.", style = MaterialTheme.typography.bodyMedium)
    }
    Row(Modifier.padding(horizontal = 8.dp)) {
        TextButton(onClick = {}) { Text("Cancel") }
        TextButton(onClick = {}) { Text("Delete") }
    }
}

Clickable

Takes onClick. The whole card reacts to clicks.

@Composable
fun Card(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    shape: Shape = CardDefaults.shape,
    colors: CardColors = CardDefaults.cardColors(),
    elevation: CardElevation = CardDefaults.cardElevation(),
    border: BorderStroke? = null,
    interactionSource: MutableInteractionSource? = null,
    content: @Composable ColumnScope.() -> Unit,
)

onClick: () -> UnitRequired

Called when the card is clicked. Only on the clickable form.

A clickable card
A clickable card
Card(onClick = { /* open details */ }, modifier = Modifier.width(280.dp)) {
    Text("Tap to open", Modifier.padding(16.dp))
}

enabled: BooleanOptional

Default: true

Set to false to make a clickable card gray and not clickable.

A disabled clickable card
A disabled clickable card
Card(onClick = {}, enabled = false, modifier = Modifier.width(280.dp)) {
    Text("Not available", Modifier.padding(16.dp))
}

interactionSource: MutableInteractionSource?Optional

Default: null

Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.

Same as above: modifier, shape, colors, elevation, border, content.

Card types

See also