SelectionControlScope

class SelectionControlScope


SelectionControlScope provides enabled and selected properties. This allows selection controls to omit enabled/selected parameters as they given by the scope.

Summary

Public constructors

SelectionControlScope(isEnabled: Boolean, isSelected: Boolean)

Public properties

Boolean

Controls the enabled state of the selection control.

Boolean

Indicates whether the control is currently selected

Extension functions

Unit

RadioButton provides an animated radio selection control for use in SelectableButton or SplitSelectableButton.

Public constructors

SelectionControlScope

Added in 1.0.0-alpha24
SelectionControlScope(isEnabled: Boolean, isSelected: Boolean)
Parameters
isEnabled: Boolean

Controls the enabled state of the selection control. When false, the control is displayed with disabled colors

isSelected: Boolean

Indicates whether the control is currently selected

Public properties

isEnabled

Added in 1.0.0-alpha24
val isEnabledBoolean

Controls the enabled state of the selection control. When false, the control is displayed with disabled colors

isSelected

Added in 1.0.0-alpha24
val isSelectedBoolean

Indicates whether the control is currently selected

Extension functions

@Composable
fun SelectionControlScope.RadioButton(
    modifier: Modifier = Modifier,
    colors: RadioButtonColors = RadioButtonDefaults.colors()
): Unit

RadioButton provides an animated radio selection control for use in SelectableButton or SplitSelectableButton.

RadioButton sample:

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material3.Icon
import androidx.wear.compose.material3.SelectableButton
import androidx.wear.compose.material3.Text

Column(modifier = Modifier.selectableGroup()) {
    var selectedButton by remember { mutableStateOf(0) }
    // RadioButton uses the Radio selection control by default.
    SelectableButton(
        label = {
            Text("Selectable button", maxLines = 3, overflow = TextOverflow.Ellipsis)
        },
        secondaryLabel = {
            Text("With secondary label", maxLines = 2, overflow = TextOverflow.Ellipsis)
        },
        selected = selectedButton == 0,
        onSelect = { selectedButton = 0 },
        icon = {
            Icon(
                Icons.Filled.Favorite,
                contentDescription = "Favorite icon"
            )
        },
        enabled = true,
    )
    Spacer(modifier = Modifier.height(4.dp))
    SelectableButton(
        label = {
            Text("Selectable button", maxLines = 3, overflow = TextOverflow.Ellipsis)
        },
        secondaryLabel = {
            Text("With secondary label", maxLines = 3, overflow = TextOverflow.Ellipsis)
        },
        selected = selectedButton == 1,
        onSelect = { selectedButton = 1 },
        icon = {
            Icon(
                Icons.Filled.Favorite,
                contentDescription = "Favorite icon"
            )
        },
        enabled = true,
    )
}
Parameters
modifier: Modifier = Modifier

Modifier to be applied to the radio button control. This can be used to provide a content description for accessibility.

colors: RadioButtonColors = RadioButtonDefaults.colors()

RadioButtonColors from which the RadioButton control colors will be obtained.