androidx.compose.material3

InputChip

Composable function

One of the chip types. It works like AssistChip. Only the parameters that differ are described here.

A chip for something the user entered, like a contact in a "To" field.

Input chip with avatar and remove icon
Input chip with avatar and remove icon
InputChip(
    selected = false,
    onClick = { /* remove */ },
    label = { Text("Alex") },
    avatar = { Icon(Icons.Filled.Person, null, Modifier.size(InputChipDefaults.AvatarSize)) },
    trailingIcon = { Icon(Icons.Filled.Close, "Remove", Modifier.size(InputChipDefaults.IconSize)) },
)

Basic

Takes one shape.

@Composable
fun InputChip(
    selected: Boolean,
    onClick: () -> Unit,
    label: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    leadingIcon: @Composable (() -> Unit)? = null,
    avatar: @Composable (() -> Unit)? = null,
    trailingIcon: @Composable (() -> Unit)? = null,
    shape: Shape = InputChipDefaults.shape,
    colors: SelectableChipColors = InputChipDefaults.inputChipColors(),
    elevation: SelectableChipElevation? = InputChipDefaults.inputChipElevation(),
    border: BorderStroke? = InputChipDefaults.inputChipBorder(enabled, selected),
    horizontalArrangement: Arrangement.Horizontal = InputChipDefaults.horizontalArrangement(),
    contentPadding: PaddingValues = InputChipDefaults.contentPadding(avatar != null, leadingIcon != null, trailingIcon != null),
    interactionSource: MutableInteractionSource? = null,
)

selected: BooleanRequired

Whether the chip is selected. Only on FilterChip and InputChip. You keep this state yourself.

Filter chips that toggle
Filter chips that toggle
var vegan by remember { mutableStateOf(true) }
var spicy by remember { mutableStateOf(false) }
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
    FilterChip(
        selected = vegan,
        onClick = { vegan = !vegan },
        label = { Text("Vegan") },
        leadingIcon = if (vegan) {
            { Icon(Icons.Filled.Done, null, Modifier.size(FilterChipDefaults.IconSize)) }
        } else null,
    )
    FilterChip(selected = spicy, onClick = { spicy = !spicy }, label = { Text("Spicy") })
}

avatar: @Composable (() -> Unit)?Optional

Default: null

A picture of a person or thing, before the label. Only on InputChip.

Input chip with avatar and remove icon
Input chip with avatar and remove icon
InputChip(
    selected = false,
    onClick = { /* remove */ },
    label = { Text("Alex") },
    avatar = { Icon(Icons.Filled.Person, null, Modifier.size(InputChipDefaults.AvatarSize)) },
    trailingIcon = { Icon(Icons.Filled.Close, "Remove", Modifier.size(InputChipDefaults.IconSize)) },
)

colors: SelectableChipColorsOptional

Default: InputChipDefaults.inputChipColors()

Sets the container, label and icon colors. Make one with the chip's defaults object, for example FilterChipDefaults.filterChipColors.

elevation: SelectableChipElevation?Optional

Default: InputChipDefaults.inputChipElevation()

Sets the shadow height. Default: flat. Use the elevated… functions in the defaults object for a raised chip.

Defaults that differ from AssistChip:

Same as in AssistChip: onClick, label, modifier, enabled, leadingIcon, trailingIcon, shape, border, horizontalArrangement, contentPadding, interactionSource.

Expressive

Takes shapes: separate shapes for rest, selected and pressed.

@Composable
fun InputChip(
    selected: Boolean,
    onClick: () -> Unit,
    label: @Composable () -> Unit,
    shapes: ChipShapes,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    leadingIcon: @Composable (() -> Unit)? = null,
    avatar: @Composable (() -> Unit)? = null,
    trailingIcon: @Composable (() -> Unit)? = null,
    colors: SelectableChipColors = InputChipDefaults.tonalInputChipColors(),
    elevation: SelectableChipElevation? = InputChipDefaults.inputChipElevation(),
    border: BorderStroke? = InputChipDefaults.inputChipBorder(enabled, selected),
    horizontalArrangement: Arrangement.Horizontal = InputChipDefaults.horizontalArrangement(avatar != null, leadingIcon != null, trailingIcon != null),
    contentPadding: PaddingValues = InputChipDefaults.contentPadding(avatar != null, leadingIcon != null, trailingIcon != null),
    interactionSource: MutableInteractionSource? = null,
)

shapes: ChipShapesRequiredSince 1.12

Sets shapes for rest, selected and pressed. Takes a ChipShapes.

Defaults that differ from AssistChip:

Same as above: selected, avatar, colors, elevation.

Same as in AssistChip: onClick, label, modifier, enabled, leadingIcon, trailingIcon, border, horizontalArrangement, contentPadding, interactionSource.

Chip types

See also