StylishConnectedCard

fun StylishConnectedCard(title: String = "", supportingText: String = "", modifier: Modifier = Modifier, shape: Shape = connectedShape(ConnectedCorners.Standalone), outlineEdges: ConnectedEdges = ConnectedEdges.All, outlineCorners: ConnectedCorners = ConnectedCorners.Standalone, containerColor: Color? = null, contentColor: Color? = null, disabledContainerColor: Color = MaterialTheme.colorScheme.surfaceVariant, disabledContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, titleStyle: TextStyle = MaterialTheme.typography.titleLarge, supportingTextStyle: TextStyle = MaterialTheme.typography.bodySmall, supportingTextColor: Color? = null, minHeight: Dp = 77.dp, horizontalPadding: Dp = 16.dp, verticalPadding: Dp = 12.dp, contentSpacing: Dp = StylishTheme.dimensions.itemSpacing, titleSpacing: Dp = StylishTheme.dimensions.inlineSpacing, enabled: Boolean = true, onClick: () -> Unit? = null, onLongClick: () -> Unit? = null, titleMaxLines: Int = 1, titleOverflow: TextOverflow = TextOverflow.Ellipsis, supportingTextMaxLines: Int = 1, supportingTextOverflow: TextOverflow = TextOverflow.Ellipsis, variant: StylishCardVariant = StylishCardVariant.Elevated, border: BorderStroke? = null, interactionSource: MutableInteractionSource? = null, leadingContent: @Composable () -> Unit? = null, trailingContent: @Composable () -> Unit? = null, content: @Composable () -> Unit? = null)

A connected card that shares edges and corner radii with adjacent cards, forming a visually continuous group. Supports tap and long-press interactions; long-press triggers haptic feedback. When neither onClick nor onLongClick is provided, the card renders flat (zero elevation) and ignores pointer input.

Use StylishConnectedCardRow, StylishConnectedCardColumn, or StylishConnectedCardGrid to lay out multiple connected cards — those layouts compute outlineEdges and outlineCorners automatically.

Two rendering modes

Structured mode (default) — when content is null, the card renders a fixed three-slot row: leadingContent | title column (title + supportingText) | trailingContent. The title column occupies the remaining width via weight(1f).

Content mode — when content is non-null, it completely replaces the structured row. The caller has full control over the card's inner layout; title, supportingText, leadingContent, trailingContent, and their style parameters (titleStyle, titleMaxLines, titleOverflow, supportingTextStyle, supportingTextMaxLines, supportingTextOverflow, contentSpacing, titleSpacing) are ignored. Container-level parameters (minHeight, horizontalPadding, verticalPadding, shape, containerColor, contentColor, disabledContainerColor, disabledContentColor) still apply in both modes.

Parameters

title

Primary text displayed in the card body in structured mode. Ignored in content mode. Defaults to "".

supportingText

Secondary text below the title in structured mode. Omitted when blank. Ignored in content mode.

modifier

Modifier applied to the card root.

shape

Shape of the card surface. Defaults to connectedShape with ConnectedCorners.Standalone.

outlineEdges

Which edges of the hairline outline to draw. Defaults to ConnectedEdges.All.

outlineCorners

Which corners use the large (outer) radius. Defaults to ConnectedCorners.Standalone.

containerColor

Background color. Defaults to stylishComponentColors.groupedContainer. Ignored when enabled is false.

contentColor

Default content color. Defaults to MaterialTheme.colorScheme.onSurface. Ignored when enabled is false.

disabledContainerColor

Background color used when enabled is false, visually dimming the card. Defaults to MaterialTheme.colorScheme.surfaceVariant.

disabledContentColor

Content color used when enabled is false, visually dimming the card. Defaults to MaterialTheme.colorScheme.onSurfaceVariant.

titleStyle

Text style for title in structured mode.

supportingTextStyle

Text style for supportingText in structured mode.

supportingTextColor

Color for supportingText in structured mode. Defaults to MaterialTheme.colorScheme.onSurfaceVariant.

minHeight

Minimum height of the card body. Defaults to 77.dp. Applies in both modes.

horizontalPadding

Horizontal padding inside the card. Defaults to 16.dp. Applies in both modes.

verticalPadding

Vertical padding inside the card. Defaults to 12.dp. Applies in both modes.

contentSpacing

Horizontal gap between slots in structured mode. Ignored in content mode.

titleSpacing

Vertical gap between title and supportingText in structured mode. Ignored in content mode.

enabled

When false, the card ignores pointer input, renders at zero elevation regardless of onClick, is announced as disabled via semantics, and is visually dimmed with disabledContainerColor and disabledContentColor.

onClick

Called when the card is tapped. null (default) makes the card display-only.

onLongClick

Called when the card is long-pressed. Triggers HapticFeedbackType.LongPress before invocation.

titleMaxLines

Maximum lines for title in structured mode.

titleOverflow

Overflow strategy for title in structured mode.

supportingTextMaxLines

Maximum lines for supportingText in structured mode.

supportingTextOverflow

Overflow strategy for supportingText in structured mode.

variant

The visual style of the card (see StylishCardVariant). Defaults to StylishCardVariant.Elevated, preserving the classic Stylish look.

border

Border stroke drawn around the card, in addition to the connected outline. When null (default), resolved from variant: a hairline of StylishTheme.dimensions.outlineWidth using MaterialTheme.colorScheme.outlineVariant for StylishCardVariant.Outlined, and no border otherwise. Pass an explicit BorderStroke to override.

interactionSource

The MutableInteractionSource for the card, used to observe press/focus/hover interactions. When null, an internal one is remembered.

leadingContent

Content before the title column in structured mode. Ignored in content mode.

trailingContent

Content after the title column in structured mode. Ignored in content mode.

content

When non-null, replaces the entire structured row with caller-supplied content, enabling fully custom card layouts. The content is placed inside a Box constrained by minHeight, horizontalPadding, and verticalPadding. When null (default), the structured three-slot row is rendered.

See also

StylishConnectedCardRow
StylishConnectedCardColumn
StylishConnectedCardGrid