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

← Back to Wear Material Core

Checkbox

Component
in
Wear Material Core
. Since 1.3.0-alpha02

Overview

Code Examples

Checkbox provides an animated checkbox for use in material APIs.

@param checked Boolean flag indicating whether this checkbox is currently checked. @param modifier Modifier to be applied to the checkbox. This can be used to provide a content description for accessibility. @param boxColor Composable lambda from which the box color will be obtained. @param checkmarkColor Composable lambda from which the check mark color will be obtained. @param enabled Boolean flag indicating the enabled state of the Checkbox (affects the color). @param onCheckedChange Callback to be invoked when Checkbox is clicked. If null, then this is passive and relies entirely on a higher-level component to control the state. @param interactionSource When also providing onCheckedChange, the MutableInteractionSource representing the stream of Interactions for the "toggleable" tap area - can be used to customise the appearance / behavior of the Checkbox. @param progressAnimationSpec Animation spec to animate the progress. @param drawBox Draws the checkbox. @param width Width of the checkbox. @param height Height of the checkbox.

Overloads

Checkbox

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Composable
fun Checkbox(
    checked: Boolean,
    modifier: Modifier = Modifier,
    boxColor: @Composable (enabled: Boolean, checked: Boolean) -> State<Color>,
    checkmarkColor: @Composable (enabled: Boolean, checked: Boolean) -> State<Color>,
    enabled: Boolean,
    onCheckedChange: ((Boolean) -> Unit)?,
    interactionSource: MutableInteractionSource,
    progressAnimationSpec: TweenSpec<Float>,
    drawBox: FunctionDrawBox,
    width: Dp,
    height: Dp
)

Parameters

NameDescription
checkedBoolean flag indicating whether this checkbox is currently checked.
modifierModifier to be applied to the checkbox. This can be used to provide a content description for accessibility.
boxColorComposable lambda from which the box color will be obtained.
checkmarkColorComposable lambda from which the check mark color will be obtained.
enabledBoolean flag indicating the enabled state of the Checkbox (affects the color).
onCheckedChangeCallback to be invoked when Checkbox is clicked. If null, then this is passive and relies entirely on a higher-level component to control the state.
interactionSourceWhen also providing onCheckedChange, the MutableInteractionSource representing the stream of Interactions for the "toggleable" tap area - can be used to customise the appearance / behavior of the Checkbox.
progressAnimationSpecAnimation spec to animate the progress.
drawBoxDraws the checkbox.
widthWidth of the checkbox.
heightHeight of the checkbox