Toggle

fun Toggle(isToggled: Boolean, onToggleChange: (Boolean) -> Unit?, modifier: Modifier = Modifier, label: String = "", actionText: String = "", isEnabled: Boolean = true, isReadOnly: Boolean = false, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() })

Carbon Toggle

A toggle is used to quickly switch between two possible states. They are commonly used for “on/off” switches.

Content

  • The toggle itself with a handle that indicates the current state.

  • The label accompanying the toggle to further clarify the action that the toggle performs.

  • The action text describing the binary action of toggle so that the action is clear.

Interactions

The component applies a toggleable interaction to the toggle root composable if the onToggleChange callback is provided, meaning that the whole component is clickable in order to create a more accessible click target. Otherwise, the toggle won't be interactable.

(From Toggle documentation)

Parameters

isToggled

Whether the toggle is toggled on or off.

onToggleChange

Callback for when the toggle is toggled.

modifier

Modifier to be applied to the toggle.

label

Label text to be displayed above the toggle.

actionText

Action text to be displayed next to the toggle.

isEnabled

Whether the toggle is enabled.

isReadOnly

Whether the toggle is read only.

interactionSource

The MutableInteractionSource to be applied to the toggle.