Card
Component in Wear Material Compose
Base level Wear Material [Card] that offers a single slot to take any content.
Is used as the container for more opinionated [Card] components that take specific content such as icons, images, titles, subtitles and labels.
The [Card] is Rectangle shaped rounded corners by default.
Cards can be enabled or disabled. A disabled card will not respond to click events.
For more information, see the Cards Wear OS Material design guide.
Note that the Wear OS design guidance recommends a gradient or image background for Cards which is not the case for Mobile Cards. As a result you will see a backgroundPainter rather than a backgroundColor for Cards. If you want to workaround this recommendation you could use a [ColorPainter] to produce a solid colored background.
Last updated:
Installation
dependencies {
implementation("androidx.wear.compose:compose-material:1.5.0-alpha04")
}
Overloads
@Composable
fun Card(
onClick: () -> Unit,
modifier: Modifier = Modifier,
backgroundPainter: Painter = CardDefaults.cardBackgroundPainter(),
contentColor: Color = MaterialTheme.colors.onSurfaceVariant,
enabled: Boolean = true,
contentPadding: PaddingValues = CardDefaults.ContentPadding,
shape: Shape = MaterialTheme.shapes.large,
interactionSource: MutableInteractionSource? = null,
role: Role? = null,
content: @Composable ColumnScope.() -> Unit,
)
Parameters
name | description |
---|---|
onClick | Will be called when the user clicks the card |
modifier | Modifier to be applied to the card |
backgroundPainter | A painter used to paint the background of the card. A card will normally have a gradient background. Use [CardDefaults.cardBackgroundPainter()] to obtain an appropriate painter |
contentColor | The default color to use for content() unless explicitly set. |
enabled | Controls the enabled state of the card. When false, this card will not be clickable and there will be no ripple effect on click. Wear cards do not have any specific elevation or alpha differences when not enabled - they are simply not clickable. |
contentPadding | The spacing values to apply internally between the container and the content |
shape | Defines the card's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material Theme |
interactionSource | an optional hoisted [MutableInteractionSource] for observing and emitting [Interaction]s for this card. You can use this to change the card's appearance or preview the card in different states. Note that if null is provided, interactions will still happen internally. |
role | The type of user interface element. Accessibility services might use this to describe the element or do customizations |
content | Slot for composable body content displayed on the Card |