CardDefaults
object CardDefaults
Contains the default values used by all card types.
Summary
Constants |
|
|---|---|
const Float |
Recommended aspect ratio |
const Float |
SquareImageAspectRatio = 1.0fRecommended aspect ratio |
const Float |
Recommended aspect ratio |
Public functions |
|
|---|---|
CardBorder |
@ComposableCreates a |
CardColors |
@ComposableCreates |
CardColors |
@ComposableCreates |
CardGlow |
Creates a |
CardScale |
scale(Creates a |
CardShape |
Creates a |
Public properties |
|
|---|---|
Brush |
Gradient used in cards to give more emphasis to the textual content that is generally displayed above an image. |
Constants
HorizontalImageAspectRatio
const val HorizontalImageAspectRatio: Float
Recommended aspect ratio Float for horizontal images, can be applied using the modifier Modifier.aspectRatio.
SquareImageAspectRatio
const val SquareImageAspectRatio = 1.0f: Float
Recommended aspect ratio Float to get square images, can be applied using the modifier Modifier.aspectRatio.
VerticalImageAspectRatio
const val VerticalImageAspectRatio: Float
Recommended aspect ratio Float for vertical images, can be applied using the modifier Modifier.aspectRatio.
Public functions
border
@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 |
focusedBorder: Border = Border(
border = BorderStroke(width = 3.dp, color = MaterialTheme.colorScheme.border),
shape = ContainerShape
) |
the |
pressedBorder: Border = focusedBorder |
the |
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
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.
scale
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
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 |
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
val ScrimBrush: Brush
Gradient used in cards to give more emphasis to the textual content that is generally displayed above an image.