CardDefaults

object CardDefaults


Contains the default values used by Card

Summary

Public functions

Painter
@Composable
cardBackgroundPainter(
    startBackgroundColor: Color,
    endBackgroundColor: Color,
    gradientDirection: LayoutDirection
)

Creates a Painter for background colors for a Card.

Painter
@Composable
imageWithScrimBackgroundPainter(
    backgroundImagePainter: Painter,
    backgroundImageScrimBrush: Brush
)

Creates a Painter for the background of a Card that displays an Image with a scrim over the image to make sure that any content above the background will be legible.

Public properties

Dp

The default size of the app icon/image when used inside a AppCard.

PaddingValues

The default content padding used by Card

Public functions

cardBackgroundPainter

@Composable
fun cardBackgroundPainter(
    startBackgroundColor: Color = MaterialTheme.colors.primary .copy(alpha = 0.30f) .compositeOver(MaterialTheme.colors.background),
    endBackgroundColor: Color = MaterialTheme.colors.onSurfaceVariant .copy(alpha = 0.20f) .compositeOver(MaterialTheme.colors.background),
    gradientDirection: LayoutDirection = LocalLayoutDirection.current
): Painter

Creates a Painter for background colors for a Card. Cards typically have a linear gradient for a background. The gradient will be between startBackgroundColor and endBackgroundColor and at an angle of 45 degrees.

Cards should have a content color that contrasts with the background gradient.

Parameters
startBackgroundColor: Color = MaterialTheme.colors.primary .copy(alpha = 0.30f) .compositeOver(MaterialTheme.colors.background)

The background color used at the start of the gradient of this Card

endBackgroundColor: Color = MaterialTheme.colors.onSurfaceVariant .copy(alpha = 0.20f) .compositeOver(MaterialTheme.colors.background)

The background color used at the end of the gradient of this Card

gradientDirection: LayoutDirection = LocalLayoutDirection.current

Whether the cards gradient should be start to end (indicated by LayoutDirection.Ltr) or end to start (indicated by LayoutDirection.Rtl).

imageWithScrimBackgroundPainter

Added in 1.0.0
@Composable
fun imageWithScrimBackgroundPainter(
    backgroundImagePainter: Painter,
    backgroundImageScrimBrush: Brush = Brush.linearGradient( colors = listOf( MaterialTheme.colors.surface.copy(alpha = 1.0f), MaterialTheme.colors.surface.copy(alpha = 0f) ) )
): Painter

Creates a Painter for the background of a Card that displays an Image with a scrim over the image to make sure that any content above the background will be legible.

An Image background is a means to reinforce the meaning of information in a Card, e.g. To help to contextualize the information in a TitleCard

Cards should have a content color that contrasts with the background image and scrim

Parameters
backgroundImagePainter: Painter

The Painter to use to draw the background of the Card

backgroundImageScrimBrush: Brush = Brush.linearGradient( colors = listOf( MaterialTheme.colors.surface.copy(alpha = 1.0f), MaterialTheme.colors.surface.copy(alpha = 0f) ) )

The Brush to use to paint a scrim over the background image to ensure that any text drawn over the image is legible

Public properties

AppImageSize

Added in 1.0.0
val AppImageSizeDp

The default size of the app icon/image when used inside a AppCard.

ContentPadding

Added in 1.0.0
val ContentPaddingPaddingValues

The default content padding used by Card