CardDefaults

object CardDefaults


Contains the default values used by all card types.

Summary

Constants

const Float

Recommended aspect ratio Float for horizontal images, can be applied using the modifier Modifier.aspectRatio.

const Float

Recommended aspect ratio Float to get square images, can be applied using the modifier Modifier.aspectRatio.

const Float

Recommended aspect ratio Float for vertical images, can be applied using the modifier Modifier.aspectRatio.

Public functions

CardBorder
@Composable
border(border: Border, focusedBorder: Border, pressedBorder: Border)

Creates a CardBorder that represents the border Borders applied on a Card in different Interaction states.

CardColors
@Composable
colors(
    containerColor: Color,
    contentColor: Color,
    focusedContainerColor: Color,
    focusedContentColor: Color,
    pressedContainerColor: Color,
    pressedContentColor: Color
)

Creates CardColors that represents the default container & content colors used in a Card.

CardColors
@Composable
compactCardColors(
    containerColor: Color,
    contentColor: Color,
    focusedContainerColor: Color,
    focusedContentColor: Color,
    pressedContainerColor: Color,
    pressedContentColor: Color
)

Creates CardColors that represents the default colors used in a Compact Card.

CardGlow
glow(glow: Glow, focusedGlow: Glow, pressedGlow: Glow)

Creates a CardGlow that represents the default Glows used in a card.

CardScale
scale(
    scale: @FloatRange(from = 0.0) Float,
    focusedScale: @FloatRange(from = 0.0) Float,
    pressedScale: @FloatRange(from = 0.0) Float
)

Creates a CardScale that represents the default scales used in a Card.

CardShape
shape(shape: Shape, focusedShape: Shape, pressedShape: Shape)

Creates a CardShape that represents the default container shapes used in a Card.

Public properties

Brush

Gradient used in cards to give more emphasis to the textual content that is generally displayed above an image.

Constants

HorizontalImageAspectRatio

Added in 1.0.0
const val HorizontalImageAspectRatioFloat

Recommended aspect ratio Float for horizontal images, can be applied using the modifier Modifier.aspectRatio.

SquareImageAspectRatio

Added in 1.0.0
const val SquareImageAspectRatio = 1.0f: Float

Recommended aspect ratio Float to get square images, can be applied using the modifier Modifier.aspectRatio.

VerticalImageAspectRatio

Added in 1.0.0
const val VerticalImageAspectRatioFloat

Recommended aspect ratio Float for vertical images, can be applied using the modifier Modifier.aspectRatio.

Public functions

border

Added in 1.0.0
@Composable
fun border(
    border: Border = Border.None,
    focusedBorder: Border = Border( border = BorderStroke(width = 3.dp, color = MaterialTheme.colorScheme.border), shape = ContainerShape ),
    pressedBorder: Border = focusedBorder
): CardBorder

Creates a CardBorder that represents the border Borders applied on a Card in different Interaction states.

Parameters
border: Border = Border.None

the default Border to be used for this Card.

focusedBorder: Border = Border( border = BorderStroke(width = 3.dp, color = MaterialTheme.colorScheme.border), shape = ContainerShape )

the Border to be used for this Card when focused.

pressedBorder: Border = focusedBorder

the Border to be used for this Card when pressed.

colors

@Composable
fun colors(
    containerColor: Color = MaterialTheme.colorScheme.surfaceVariant,
    contentColor: Color = contentColorFor(containerColor),
    focusedContainerColor: Color = containerColor,
    focusedContentColor: Color = contentColorFor(focusedContainerColor),
    pressedContainerColor: Color = focusedContainerColor,
    pressedContentColor: Color = contentColorFor(pressedContainerColor)
): CardColors

Creates CardColors that represents the default container & content colors used in a Card.

Parameters
containerColor: Color = MaterialTheme.colorScheme.surfaceVariant

the default container color of this Card.

contentColor: Color = contentColorFor(containerColor)

the default content color of this Card.

focusedContainerColor: Color = containerColor

the container color of this Card when focused.

focusedContentColor: Color = contentColorFor(focusedContainerColor)

the content color of this Card when focused.

pressedContainerColor: Color = focusedContainerColor

the container color of this Card when pressed.

pressedContentColor: Color = contentColorFor(pressedContainerColor)

the content color of this Card when pressed.

compactCardColors

@Composable
fun compactCardColors(
    containerColor: Color = MaterialTheme.colorScheme.surfaceVariant,
    contentColor: Color = Color.White,
    focusedContainerColor: Color = containerColor,
    focusedContentColor: Color = contentColor,
    pressedContainerColor: Color = focusedContainerColor,
    pressedContentColor: Color = focusedContentColor
): CardColors

Creates CardColors that represents the default colors used in a Compact Card.

Parameters
containerColor: Color = MaterialTheme.colorScheme.surfaceVariant

the default container color of this Card.

contentColor: Color = Color.White

the default content color of this Card.

focusedContainerColor: Color = containerColor

the container color of this Card when focused.

focusedContentColor: Color = contentColor

the content color of this Card when focused.

pressedContainerColor: Color = focusedContainerColor

the container color of this Card when pressed.

pressedContentColor: Color = focusedContentColor

the content color of this Card when pressed.

glow

Added in 1.0.0
fun glow(glow: Glow = Glow.None, focusedGlow: Glow = glow, pressedGlow: Glow = glow): CardGlow

Creates a CardGlow that represents the default Glows used in a card.

Parameters
glow: Glow = Glow.None

the default Glow behind this Card.

focusedGlow: Glow = glow

the Glow behind this Card when focused.

pressedGlow: Glow = glow

the Glow behind this Card when pressed.

scale

Added in 1.0.0
fun scale(
    scale: @FloatRange(from = 0.0) Float = 1.0f,
    focusedScale: @FloatRange(from = 0.0) Float = 1.1f,
    pressedScale: @FloatRange(from = 0.0) Float = scale
): CardScale

Creates a CardScale that represents the default scales used in a Card. Scales are used to modify the size of a composable in different Interaction states e.g. 1f (original) in default state, 1.1f (scaled up) in focused state, 0.8f (scaled down) in pressed state, etc.

Parameters
scale: @FloatRange(from = 0.0) Float = 1.0f

the default scale to be used for this Card.

focusedScale: @FloatRange(from = 0.0) Float = 1.1f

the scale to be used for this Card when focused.

pressedScale: @FloatRange(from = 0.0) Float = scale

the scale to be used for this Card when pressed.

shape

Added in 1.0.0
fun shape(
    shape: Shape = ContainerShape,
    focusedShape: Shape = shape,
    pressedShape: Shape = shape
): CardShape

Creates a CardShape that represents the default container shapes used in a Card.

Parameters
shape: Shape = ContainerShape

the default shape used when the Card has no other Interactions.

focusedShape: Shape = shape

the shape used when the Card is focused.

pressedShape: Shape = shape

the shape used when the Card is pressed.

Public properties

ScrimBrush

Added in 1.0.0
val ScrimBrushBrush

Gradient used in cards to give more emphasis to the textual content that is generally displayed above an image.