StylishChip

fun StylishChip(label: String = "", onClick: () -> Unit? = null, modifier: Modifier = Modifier, variant: StylishChipVariant = StylishChipVariant.Assist, selected: Boolean = false, enabled: Boolean = true, interactionSource: MutableInteractionSource? = null, shape: Shape = RoundedCornerShape(StylishTheme.dimensions.connectedCornerRadius), labelMaxLines: Int = 1, labelOverflow: TextOverflow = TextOverflow.Ellipsis, labelStyle: TextStyle = MaterialTheme.typography.labelLarge, selectedContainerColor: Color = MaterialTheme.colorScheme.primary, selectedContentColor: Color = MaterialTheme.colorScheme.onPrimary, unselectedContainerColor: Color? = null, unselectedContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, disabledContainerColor: Color = MaterialTheme.colorScheme.surfaceVariant, disabledContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, contentPadding: PaddingValues = PaddingValues(horizontal = 14.dp, vertical = 10.dp), contentSpacing: Dp = StylishTheme.dimensions.inlineSpacing, leadingContent: @Composable RowScope.() -> Unit? = null, trailingContent: @Composable RowScope.() -> Unit? = null, content: @Composable RowScope.() -> Unit? = null)

A standalone Stylish chip with the same visual language as the connected-chip family — animated selection colors, Role.Tab semantics, interactive elevation, and a haptic pulse on tap — but without any connected-group geometry. Use this when a single chip is needed outside a StylishConnectedChipRow, StylishConnectedChipColumn, or StylishConnectedChipGrid.

For the StylishChipVariant.Filter variant, a checkmark is rendered automatically before the label when selected is true and no leadingContent is provided. For the StylishChipVariant.Input variant, the container defaults to surfaceVariant and a trailing close affordance can be supplied via trailingContent.

When onClick is null the chip is display-only: no Role.Tab semantics, no ripple, and no elevation lift. When enabled is false, the chip is announced as disabled via semantics. When actionable, a Material-style state layer (see Modifier.stylishStateLayer) darkens the surface on hover and press, and a primary-colored focus ring (see Modifier.stylishFocusRing) is drawn around the chip while it holds keyboard focus.

The selected/unselected color transition animates with StylishTheme.animation.durationShort; when the platform requests reduced motion (see isStylishReducedMotionEnabled) the color snaps to its target instead of tweening.

Testing

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

Parameters

label

Text displayed on the chip in structured mode. Ignored in content mode. Defaults to "".

onClick

Called when the chip is tapped. null makes the chip display-only.

modifier

Modifier applied to the Surface root.

variant

The visual role of the chip (see StylishChipVariant).

selected

When true, the chip renders in the selected color scheme. For the StylishChipVariant.Filter variant, also renders an automatic checkmark when leadingContent is null.

enabled

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

interactionSource

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

shape

Corner shape. Defaults to RoundedCornerShape with StylishTheme.dimensions.connectedCornerRadius.

labelMaxLines

Maximum lines for label in structured mode.

labelOverflow

Overflow strategy for label in structured mode.

labelStyle

Text style for label in structured mode.

selectedContainerColor

Background color when selected.

selectedContentColor

Content color when selected.

unselectedContainerColor

Background color when unselected. When null (default), resolved from variant: surfaceVariant for StylishChipVariant.Input and stylishComponentColors.groupedContainer otherwise.

unselectedContentColor

Content color when unselected.

disabledContainerColor

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

disabledContentColor

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

contentPadding

Inner padding of the chip.

contentSpacing

Gap between leading slot, label, and trailing slot in structured mode. Defaults to StylishTheme.dimensions.inlineSpacing.

leadingContent

Optional content before the label in structured mode. Ignored in content mode. For the filter variant, a provided leading content replaces the automatic checkmark.

trailingContent

Optional content after the label in structured mode. Ignored in content mode. Use this for the StylishChipVariant.Input close affordance.

content

When non-null, replaces the entire structured row (leading + label + trailing) with caller-supplied content. Receives RowScope for weight/alignment control. When null (default), the structured row is rendered.

See also

StylishConnectedChipRow
StylishConnectedChipColumn
StylishConnectedChipGrid