Components
Checkbox
Tri-state selection controls featuring custom sizes, helper/error/warning/success validation descriptions, required flags, and disabled states
The UX4G Checkbox suite provides accessible multi-selection and declaration controls supporting boolean (true/false) and indeterminate (null) tri-state values, context validation descriptions, and required field asterisks:
- Interactive Tri-State: Supports Checked (
true), Unchecked (false), and Indeterminate (null). - Context Validation: Built-in description variants (
Helper,Error,Warning,Success) for form feedback. - Required Field Support: Automatic red asterisk indicator (
*) appended to the label withisRequired = true. - Preset Sizes: Standardized dimension tokens (
Small16dp,Medium20dp,Large24dp). - Disabled States: Compliant muted accessibility states for non-interactive forms.
Import from com.ux4g.designsystemv1.components.Ux4gCheckbox.
Interactive Preview
Ux4gCheckbox - States & LabelsJetpack Compose

Kotlin Usage
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.Ux4gCheckbox
import com.ux4g.designsystemv1.components.Ux4gCheckboxDescriptionVariant
import com.ux4g.designsystemv1.components.Ux4gCheckboxSize
import com.ux4g.designsystemv1.foundation.Ux4gColors
import com.ux4g.designsystemv1.foundation.Ux4gIcons
import com.ux4g.designsystemv1.foundation.defaultTypography
@Composable
fun CheckboxShowcaseScreen() {
Surface(color = Ux4gColors.white) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
// 1. Medium Checked with Helper
var val1 by remember { mutableStateOf<Boolean?>(true) }
Ux4gCheckbox(
value = val1,
onValueChange = { val1 = it },
label = "Medium Checked",
size = Ux4gCheckboxSize.Medium,
description = "This is a helper description",
descriptionVariant = Ux4gCheckboxDescriptionVariant.Helper
)
// 2. Large Unchecked Required with Error
var val2 by remember { mutableStateOf<Boolean?>(false) }
Ux4gCheckbox(
value = val2,
onValueChange = { val2 = it },
label = "Large Unchecked Required",
size = Ux4gCheckboxSize.Large,
isRequired = true,
description = "This field is required",
descriptionVariant = Ux4gCheckboxDescriptionVariant.Error
)
// 3. Small Indeterminate with Warning
var val3 by remember { mutableStateOf<Boolean?>(null) }
Ux4gCheckbox(
value = val3,
onValueChange = { val3 = it },
label = "Small Indeterminate Warning",
size = Ux4gCheckboxSize.Small,
description = "This is a warning",
descriptionVariant = Ux4gCheckboxDescriptionVariant.Warning,
trailingIcon = Ux4gIcons.Settings
)
// 4. Medium Success State
var val4 by remember { mutableStateOf<Boolean?>(true) }
Ux4gCheckbox(
value = val4,
onValueChange = { val4 = it },
label = "Medium Success",
size = Ux4gCheckboxSize.Medium,
description = "Successfully validated",
descriptionVariant = Ux4gCheckboxDescriptionVariant.Success
)
// 5. Disabled Non-Interactive States
Text(
text = "Disabled States",
style = defaultTypography.hS_default,
color = Ux4gColors.neutral900
)
Ux4gCheckbox(
value = false,
onValueChange = {},
label = "Disabled Unchecked",
size = Ux4gCheckboxSize.Medium,
isRequired = true,
enabled = false
)
Ux4gCheckbox(
value = true,
onValueChange = {},
label = "Disabled Checked",
size = Ux4gCheckboxSize.Medium,
isRequired = true,
enabled = false
)
Ux4gCheckbox(
value = null,
onValueChange = {},
label = "Disabled Indeterminate",
size = Ux4gCheckboxSize.Medium,
isRequired = true,
enabled = false
)
}
}
}Parameters
Ux4gCheckbox Props
| Prop | Type | Description | Default |
|---|---|---|---|
value * | Boolean? | Tri-state value: true (Checked), false (Unchecked), null (Indeterminate). | — |
onValueChange * | (Boolean?) -> Unit | Callback invoked when citizen taps the checkbox. | — |
modifier | Modifier | Compose layout modifier applied to outer row. | Modifier |
label | String? | Primary label text displayed next to checkbox box. | null |
description | String? | Secondary helper or validation message displayed below label. | null |
size | Ux4gCheckboxSize | Checkbox box & typography dimension preset: Small, Medium, Large. | Ux4gCheckboxSize.Medium |
isRequired | Boolean | When true, appends red asterisk (*) to the label. | false |
hasError | Boolean | Forces checkbox border into red error color state. | false |
descriptionVariant | Ux4gCheckboxDescriptionVariant | Visual feedback tone: Helper, Error, Warning, Success. | Ux4gCheckboxDescriptionVariant.Helper |
enabled | Boolean | Whether checkbox responds to citizen touch interaction. | true |
trailingIcon | Ux4gIcon? | Optional icon composable displayed after label text. | null |
checkedIcon | Ux4gIcon? | Custom icon replacing default white checkmark tick. | null |
indeterminateIcon | Ux4gIcon? | Custom icon replacing default horizontal minus bar. | null |
interactionSource | MutableInteractionSource | Interaction state tracker for ripple touch effects. | remember { MutableInteractionSource() } |
Ux4gCheckboxSize Enum
| Token | Box Dimensions | Typography Style |
|---|---|---|
Small | 16.dp x 16.dp | Label Medium (12.sp) |
Medium | 20.dp x 20.dp | Label Large (14.sp) |
Large | 24.dp x 24.dp | Label XL (16.sp) |
Ux4gCheckboxDescriptionVariant Enum
| Variant | Text Color | Intended Context |
|---|---|---|
Helper | Neutral Gray (#374151) | General guidance and supplementary explanation. |
Error | Red (#DC2626) | Mandatory checkbox missing, validation failed. |
Warning | Orange (#EA580C) | Cautionary guidance (e.g. battery drain, permission note). |
Success | Green (#16A34A) | Successful Aadhaar/consent verification. |