ToggleChip

Composable Component

A ToggleChip is a specialized type of Chip that includes a slot for a bi-state toggle control such as a toggle or checkbox. This overload provides suitable accessibility semantics for a toggleable control like Checkbox and Switch. For selectable controls like RadioButton, use SelectableChip in order to provide the correct semantics for accessibility.

Android
@Composable
public fun ToggleChip(
    checked: Boolean,
    onCheckedChange: (Boolean) -> Unit,
    label: @Composable RowScope.() -> Unit,
    toggleControl: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    appIcon: @Composable (BoxScope.() -> Unit)? = null,
    secondaryLabel: @Composable (RowScope.() -> Unit)? = null,
    colors: ToggleChipColors = ToggleChipDefaults.toggleChipColors(),
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource? = null,
    contentPadding: PaddingValues = ToggleChipDefaults.ContentPadding,
    shape: Shape = MaterialTheme.shapes.large,
): Unit

Parameters

checkedBoolean flag indicating whether this button is currently checked.
onCheckedChangeCallback to be invoked when this button's checked status changes
labelA slot for providing the chip's main label. The contents are expected to be text which is "start" aligned.
toggleControlA slot for providing the chip's toggle control. Two built-in types of toggle control are supported - Checkbox and Switch. For RadioButton, use SelectableChip, in order to provide the correct semantics for accessibility.
modifierModifier to be applied to the chip
appIconAn optional slot for providing an icon to indicate the purpose of the chip. The contents are expected to be a horizontally and vertically centre aligned icon of size ToggleChipDefaults.IconSize. In order to correctly render when the Chip is not enabled the icon must set its alpha value to LocalContentAlpha.
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.
colorsToggleChipColors that will be used to resolve the background and content color for this chip in different states, see ToggleChipDefaults.toggleChipColors.
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's "toggleable" tap area. 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