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

← Back to Glance AppWidget

CheckBox

Component
in
Glance AppWidget
. Since 1.0.0

Overview

Code Examples

Video

Adds a check box view to the glance view.

@param checked whether the check box is checked @param onCheckedChange the action to be run when the checkbox is clicked. The current value of checked is provided to this action in its ActionParameters, and can be retrieved using the ToggleableStateKey. If this action launches an activity, the current value of checked will be passed as an intent extra with the name RemoteViews.EXTRA_CHECKED. @param modifier the modifier to apply to the check box @param text the text to display to the end of the check box @param style the style to apply to text @param colors the color tint to apply to the check box @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

CheckBox

@Composable
fun CheckBox(
    checked: Boolean,
    onCheckedChange: Action?,
    modifier: GlanceModifier = GlanceModifier,
    text: String = "",
    style: TextStyle? = null,
    colors: CheckBoxColors = CheckBoxColors(),
    maxLines: Int = Int.MAX_VALUE,
)

Parameters

NameDescription
checkedwhether the check box is checked
onCheckedChangethe action to be run when the checkbox is clicked. The current value of checked is provided to this action in its ActionParameters, and can be retrieved using the ToggleableStateKey. If this action launches an activity, the current value of checked will be passed as an intent extra with the name RemoteViews.EXTRA_CHECKED.
modifierthe modifier to apply to the check box
textthe text to display to the end of the check box
stylethe style to apply to text
colorsthe color tint to apply to the check box
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