State of Compose 2023 results are in! Click here to learn more

← Back to Glance AppWidget

RadioButton

Component
in
Glance AppWidget
. Since 1.0.0

Overview

Code Examples

Video

Adds a radio button to the glance view.

When showing a Row or Column that has RadioButton children, use GlanceModifier.selectableGroup to enable the radio group effect (unselecting the previously selected radio button when another is selected).

@param checked whether the radio button is checked @param onClick the action to be run when the radio button is clicked @param modifier the modifier to apply to the radio button @param enabled if false, the radio button will not be clickable @param text the text to display to the end of the radio button @param style the style to apply to text @param colors the color tint to apply to the radio button @param maxLines An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated.

Overloads

RadioButton

@Composable
fun RadioButton(
    checked: Boolean,
    onClick: Action?,
    modifier: GlanceModifier = GlanceModifier,
    enabled: Boolean = true,
    text: String = "",
    style: TextStyle? = null,
    colors: RadioButtonColors = RadioButtonColors(),
    maxLines: Int = Int.MAX_VALUE,
)

Parameters

NameDescription
checkedwhether the radio button is checked
onClickthe action to be run when the radio button is clicked
modifierthe modifier to apply to the radio button
enabledif false, the radio button will not be clickable
textthe text to display to the end of the radio button
stylethe style to apply to text
colorsthe color tint to apply to the radio button
maxLinesAn optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated