RadioButton

fun RadioButton(isSelected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, isEnabled: Boolean = true, hasError: Boolean = false, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() })

A radio button is a component that allows users to select one option from a set. Use radio buttons for exclusive selection, if you think that the user needs to see all available options side-by-side.

Radio Button Sample

States

The radio button can be in different states that can be toggled with the isEnabled and hasError parameters.

Disabled

Disabled Radio Button Sample

Error

Error Radio Button Sample

Parameters

isSelected

Whether the radio button is selected or not.

onClick

The Lambda to be invoked when the radio button is clicked.

modifier

An optional Modifier to be applied to the radio button. Defaults to Modifier.

isEnabled

Whether the radio button is enabled or not. Defaults to true.

hasError

Whether the radio button is in an error state or not. Defaults to false.

interactionSource

An optional hoisted MutableInteractionSource for observing and emitting Interactions for the radio button. You can use this to change the radio button's appearance or preview the radio button in different states. Defaults to a remembered MutableInteractionSource.