Chip

Composable Component

Base level Wear Material Chip that offers a single slot to take any content.

Android

Deprecated This overload is provided for backwards compatibility with Compose for Wear OS 1.0.A newer overload is available with an additional border parameter.

@Composable
public fun Chip(
    onClick: () -> Unit,
    colors: ChipColors,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    contentPadding: PaddingValues = ChipDefaults.ContentPadding,
    shape: Shape = MaterialTheme.shapes.large,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    role: Role? = Role.Button,
    content: @Composable RowScope.() -> Unit,
): Unit

Parameters

onClickWill be called when the user clicks the chip
colorsChipColors that will be used to resolve the background and content color for this chip in different states. See ChipDefaults.chipColors.
modifierModifier to be applied to the chip
enabledControls the enabled state of the chip. When false, this chip will not be clickable
contentPaddingThe spacing values to apply internally between the container and the content
shapeDefines the chip's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material Theme
interactionSourceThe MutableInteractionSource representing the stream of Interactions for this Chip. You can create and pass in your own remembered MutableInteractionSource if you want to observe Interactions and customize the appearance / behavior of this Chip in different Interactions.
roleThe type of user interface element. Accessibility services might use this to describe the element or do customizations
Android
@Composable
public fun Chip(
    onClick: () -> Unit,
    colors: ChipColors,
    border: ChipBorder,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    contentPadding: PaddingValues = ChipDefaults.ContentPadding,
    shape: Shape = MaterialTheme.shapes.large,
    interactionSource: MutableInteractionSource? = null,
    role: Role? = Role.Button,
    content: @Composable RowScope.() -> Unit,
)

Parameters

onClickWill be called when the user clicks the chip
colorsChipColors that will be used to resolve the background and content color for this chip in different states. See ChipDefaults.chipColors.
borderChipBorder that will be used to resolve the border for this chip in different states. See ChipDefaults.chipBorder.
modifierModifier to be applied to the chip
enabledControls the enabled state of the chip. When false, this chip will not be clickable
contentPaddingThe spacing values to apply internally between the container and the content
shapeDefines the chip's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material Theme
interactionSourcean 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.
roleThe type of user interface element. Accessibility services might use this to describe the element or do customizations
contentSlot for composable body content displayed on the Chip
Android

Deprecated This overload is provided for backwards compatibility with Compose for Wear OS 1.0.A newer overload is available with an additional shape parameter.

@Composable
public fun Chip(
    label: @Composable RowScope.() -> Unit,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    secondaryLabel: (@Composable RowScope.() -> Unit)? = null,
    icon: (@Composable BoxScope.() -> Unit)? = null,
    colors: ChipColors = ChipDefaults.primaryChipColors(),
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    contentPadding: PaddingValues = ChipDefaults.ContentPadding,
): Unit

Parameters

labelA slot for providing the chip's main label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not.
onClickWill be called when the user clicks the chip
modifierModifier to be applied to the chip
secondaryLabelA slot for providing the chip's secondary label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not. label and secondaryLabel contents should be consistently aligned.
iconA slot for providing the chip's icon. The contents are expected to be a horizontally and vertically aligned icon of size ChipDefaults.IconSize or ChipDefaults.LargeIconSize. In order to correctly render when the Chip is not enabled the icon must set its alpha value to LocalContentAlpha.
colorsChipColors that will be used to resolve the background and content color for this chip in different states. See ChipDefaults.chipColors. Defaults to ChipDefaults.primaryChipColors
enabledControls the enabled state of the chip. When false, this chip will not be clickable
interactionSourceThe MutableInteractionSource representing the stream of Interactions for this Chip. You can create and pass in your own remembered MutableInteractionSource if you want to observe Interactions and customize the appearance / behavior of this Chip in different Interactions.
contentPaddingThe spacing values to apply internally between the container and the content
Android
@Composable
public fun Chip(
    label: @Composable RowScope.() -> Unit,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    secondaryLabel: (@Composable RowScope.() -> Unit)? = null,
    icon: (@Composable BoxScope.() -> Unit)? = null,
    colors: ChipColors = ChipDefaults.primaryChipColors(),
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource? = null,
    contentPadding: PaddingValues = ChipDefaults.ContentPadding,
    shape: Shape = MaterialTheme.shapes.large,
    border: ChipBorder = ChipDefaults.chipBorder(),
)

Parameters

labelA slot for providing the chip's main label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not.
onClickWill be called when the user clicks the chip
modifierModifier to be applied to the chip
secondaryLabelA slot for providing the chip's secondary label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not. label and secondaryLabel contents should be consistently aligned.
iconA slot for providing the chip's icon. The contents are expected to be a horizontally and vertically aligned icon of size ChipDefaults.IconSize or ChipDefaults.LargeIconSize. In order to correctly render when the Chip is not enabled the icon must set its alpha value to LocalContentAlpha.
colorsChipColors that will be used to resolve the background and content color for this chip in different states. See ChipDefaults.chipColors. Defaults to ChipDefaults.primaryChipColors
enabledControls the enabled state of the chip. When false, this chip will not be clickable
interactionSourcean 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.
contentPaddingThe spacing values to apply internally between the container and the content
shapeDefines the chip's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material Theme
borderChipBorder that will be used to resolve the chip border in different states. See ChipDefaults.chipBorder.