Android 12 Developer Preview is here! Try it out, and give us your feedback!

androidx.compose.foundation.selection

Extension functions summary

For Modifier
Modifier
Modifier.selectable(selected: Boolean, enabled: Boolean = true, role: Role? = null, onClick: () -> Unit)

Configure component to be selectable, usually as a part of a mutually exclusive group, where only one item can be selected at any point in time.

Modifier
Modifier.selectable(selected: Boolean, interactionSource: MutableInteractionSource, indication: Indication?, enabled: Boolean = true, role: Role? = null, onClick: () -> Unit)

Configure component to be selectable, usually as a part of a mutually exclusive group, where only one item can be selected at any point in time.

Modifier

Use this modifier to group a list of selectable items like Tabs or RadioButtons together for accessibility purpose.

Modifier
Modifier.toggleable(value: Boolean, enabled: Boolean = true, role: Role? = null, onValueChange: (Boolean) -> Unit)

Configure component to make it toggleable via input and accessibility events

Modifier
Modifier.toggleable(value: Boolean, interactionSource: MutableInteractionSource, indication: Indication?, enabled: Boolean = true, role: Role? = null, onValueChange: (Boolean) -> Unit)

Configure component to make it toggleable via input and accessibility events.

Modifier
Modifier.triStateToggleable(state: ToggleableState, enabled: Boolean = true, role: Role? = null, onClick: () -> Unit)

Configure component to make it toggleable via input and accessibility events with three states: On, Off and Indeterminate.

Modifier
Modifier.triStateToggleable(state: ToggleableState, interactionSource: MutableInteractionSource, indication: Indication?, enabled: Boolean = true, role: Role? = null, onClick: () -> Unit)

Configure component to make it toggleable via input and accessibility events with three states: On, Off and Indeterminate.

Extension functions

selectable

fun Modifier.selectable(
    selected: Boolean,
    enabled: Boolean = true,