Checkbox in Android using Jetpack Compose Last Updated : 28 Feb, 2025 Comments Improve Suggest changes Like Article Like Report The checkbox is a composable function that is used to represent two states of any item in Android. It is used to differentiate an item from the list of items. In this article, we will take a look at the implementation of Simple Checkbox in Android using Jetpack Compose. Attributes of CheckboxAttributesUseschecked this is used to set our checkbox checked or unchecked on app launch.onCheckedChange this is a callback that will receive when there is a change in events whether the checkbox is checked or unchecked.modifier this is used to add beautification to our checkbox in the sense of padding, margin, and other properties. color this parameter is used to add color to our checkbox in the default case the checkbox color is a secondary color in the app theme.enabledthis parameter is used to add a boolean value that determines whether the checkbox is enabled.interactionSourcethis parameter uses an interaction source that handles interaction events for the checkbox.Step-by-Step ImplementationStep 1: Create a New ProjectTo create a new project in the Android Studio please refer to How to Create a new Project in Android Studio with Jetpack Compose.Step 2: Working with the MainActivity.kt fileNavigate to the app > java > {package name} > MainActivity.kt file. Inside that file add the below code to it. Comments are added inside the code to help you understand the code in more detail.MainActivity.kt: Kotlin package com.geeksforgeeks.demo import android.os.Bundle import androidx.activity.* import androidx.activity.compose.setContent import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.* import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContent { Column { Component() } } } } @Composable fun Component() { // set the state of our checkbox. val isChecked = remember { mutableStateOf(false) } // creating a checkbox in a Column. Column( modifier = Modifier .fillMaxWidth() .fillMaxHeight() .padding(16.dp), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { Checkbox( // set the state of checkbox. checked = isChecked.value, onCheckedChange = { isChecked.value = it }, modifier = Modifier.padding(8.dp), enabled = true, colors = CheckboxDefaults.colors( checkedColor = Color.Green, uncheckedColor = Color.DarkGray, checkmarkColor = Color.White ), interactionSource = remember { MutableInteractionSource() } ) Text( text = if (isChecked.value) "Checked" else "Unchecked", modifier = Modifier.padding(top = 8.dp) ) } } Output: Comment More infoAdvertise with us Next Article Checkbox in Android using Jetpack Compose C chaitanyamunje Follow Improve Article Tags : Technical Scripter Kotlin Android Technical Scripter 2020 Android-Jetpack +1 More Similar Reads Button in Android using Jetpack Compose Jetpack Compose is a new toolkit provided by Google. This is useful for designing beautiful UI designs. A Button is a UI component in Android which is used to navigate between different screens. With the help of a button, the user can interact with your app and perform multiple actions inside your a 3 min read Text Clock in Android using Jetpack Compose Text Clock is a UI widget in android which is used to display the current time in android applications. This widget displays the current time in a simple text view. The text clock widget displays a time in 12 and 24 hours format. In this article, we will take a look at How to use the TextClock widge 2 min read Text in Android using Jetpack Compose Jetpack Compose is a new toolkit provided by Google. This is useful for designing beautiful UI designs. Android Text is a simple view in Android which is used to display text inside our App. In this article, we will take a look at the implementation of Text in Android using Jetpack Compose. Importan 5 min read Custom Chips using Jetpack Compose in Android Chips in android are one of the components which are used to make the choice filters, actions, and display the selectable options in the compact area of the Android Window. In this article, we will use Android's Jetpack Compose to create those chips. A sample image is given below to give an idea of 5 min read Switch Button in Android using Jetpack Compose A Switch or a Switch Button in Android is a UI element that is used to switch between two states upon click. It can be assumed as a Boolean button with two different values. Some states where you may find a Switch in your Android device can be WIFI ON and OFF, Bluetooth ON and OFF, Dark Mode and Lig 2 min read Like