AssistChip

Functions summary

Unit
@Composable
AssistChip(
    onClick: () -> Unit,
    label: @Composable () -> Unit,
    modifier: Modifier,
    enabled: Boolean,
    leadingIcon: (@Composable () -> Unit)?,
    trailingIcon: (@Composable () -> Unit)?,
    shape: Shape,
    colors: ChipColors,
    elevation: ChipElevation?,
    border: BorderStroke?,
    horizontalArrangement: Arrangement.Horizontal,
    contentPadding: PaddingValues,
    interactionSource: MutableInteractionSource?
)

Material Design assist chip

Cmn

Functions

@Composable
fun AssistChip(
    onClick: () -> Unit,
    label: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    leadingIcon: (@Composable () -> Unit)? = null,
    trailingIcon: (@Composable () -> Unit)? = null,
    shape: Shape = AssistChipDefaults.shape,
    colors: ChipColors = AssistChipDefaults.assistChipColors(),
    elevation: ChipElevation? = AssistChipDefaults.assistChipElevation(),
    border: BorderStroke? = AssistChipDefaults.assistChipBorder(enabled),
    horizontalArrangement: Arrangement.Horizontal = AssistChipDefaults.horizontalArrangement(),
    contentPadding: PaddingValues = AssistChipDefaults.ContentPadding,
    interactionSource: MutableInteractionSource? = null
): Unit

Material Design assist chip

Chips help people enter information, make selections, filter content, or trigger actions. Chips can show multiple interactive elements together in the same area, such as a list of selectable movie times, or a series of email contacts.

Assist chips represent smart or automated actions that can span multiple apps, such as opening a calendar event from the home screen. Assist chips function as though the user asked an assistant to complete the action. They should appear dynamically and contextually in a UI.

Assist chip
image

This assist chip is applied with a flat style. If you want an elevated style, use the ElevatedAssistChip.

Example of a flat AssistChip:

import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.AssistChip
import androidx.compose.material3.AssistChipDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier

AssistChip(
    onClick = { /* Do something! */ },
    label = { Text("Assist Chip") },
    leadingIcon = {
        Icon(
            Icons.Filled.Settings,
            contentDescription = "Localized description",
            Modifier.size(AssistChipDefaults.IconSize),
        )
    },
)
Parameters
onClick: () -> Unit

called when this chip is clicked

label: @Composable () -> Unit

text label for this chip

modifier: Modifier = Modifier

the Modifier to be applied to this chip

enabled: Boolean = true

controls the enabled state of this chip. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.

leadingIcon: (@Composable () -> Unit)? = null

optional icon at the start of the chip, preceding the label text

trailingIcon: (@Composable () -> Unit)? = null

optional icon at the end of the chip

shape: Shape = AssistChipDefaults.shape

defines the shape of this chip's container, border (when border is not null), and shadow (when using elevation)

colors: ChipColors = AssistChipDefaults.assistChipColors()

ChipColors that will be used to resolve the colors used for this chip in different states. See AssistChipDefaults.assistChipColors.

elevation: ChipElevation? = AssistChipDefaults.assistChipElevation()

ChipElevation used to resolve the elevation for this chip in different states. This controls the size of the shadow below the chip. Additionally, when the container color is ColorScheme.surface, this controls the amount of primary color applied as an overlay. See AssistChipDefaults.assistChipElevation.

border: BorderStroke? = AssistChipDefaults.assistChipBorder(enabled)

the border to draw around the container of this chip. Pass null for no border. See AssistChipDefaults.assistChipBorder.

horizontalArrangement: Arrangement.Horizontal = AssistChipDefaults.horizontalArrangement()

the horizontal arrangement of the chip's children. If there aren't icons, then the horizontal padding between the label and the border will be the sum of contentPadding and the spacing in this horizontalArrangement.

contentPadding: PaddingValues = AssistChipDefaults.ContentPadding

the padding around the content of this chip, including the leadingIcon, label, and trailingIcon. See AssistChipDefaults.ContentPadding.

interactionSource: MutableInteractionSource? = null

an optional hoisted MutableInteractionSource for observing and emitting Interactions for this chip. You can use this to change the chip's appearance or preview the chip in different states. Note that if null is provided, interactions will still happen internally.