StylishCard

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

A standalone card for presenting a single piece of grouped content. 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.

This is the standalone card — it carries no connected-group geometry. Use StylishConnectedCard, StylishConnectedCardRow, StylishConnectedCardColumn, or StylishConnectedCardGrid when multiple cards should share edges and corner radii as a visually continuous group.

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) still apply in both modes.

Testing

The root carries the default test tag stylish_card for UI tests. Callers can override it by passing their own Modifier.testTag(...) in modifier.

Parameters

modifier

Modifier applied to the Card root.

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.

enabled

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

variant

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

shape

Shape of the card surface. Defaults to RoundedCornerShape with StylishTheme.dimensions.connectedCornerRadius.

containerColor

Background color. Defaults to stylishComponentColors.groupedContainer.

contentColor

Default content color. Defaults to MaterialTheme.colorScheme.onSurface.

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.

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.

titleStyle

Text style for title in structured mode.

titleMaxLines

Maximum lines for title in structured mode.

titleOverflow

Overflow strategy for title in structured mode.

supportingTextStyle

Text style for supportingText in structured mode.

supportingTextMaxLines

Maximum lines for supportingText in structured mode.

supportingTextOverflow

Overflow strategy for supportingText in structured mode.

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.

border

Border stroke drawn around the card. 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