Components
Aadhaar Input
Specialized 12-digit Indian Aadhaar number input with auto-formatting chunks and real-time Verhoeff checksum algorithm validation
The Ux4gAadhaarInputField is a specialized citizen identity input component designed specifically for 12-digit Indian Aadhaar numbers.
It features:
- Auto-Formatting: Automatically chunks raw numeric entry into
XXXX XXXX XXXX(space inserted after every 4 digits). - Numeric-Only Filtering: Rejects any non-digit input automatically.
- Masking Toggle: Built-in show/hide toggle with Material Outlined Eye icons (
Visibility/VisibilityOff). - Verhoeff Checksum Algorithm: Validates the 12th checksum digit in real-time according to official UIDAI specifications.
- Dynamic Status Updates: Automatically transitions to
Ux4gInputFieldStatus.Success("Valid Aadhaar number") orUx4gInputFieldStatus.Error("Please enter a valid Aadhaar number") upon entering 12 digits.
Import from com.ux4g.designsystemv1.components.inputfield.Ux4gAadhaarInputField.
Interactive Previews
1. Default State with Mask Toggle
Default empty state displaying field label, chunked placeholder format, helper caption, and eye-off mask visibility toggle.
Ux4gAadhaarInputField (Default State)Jetpack Compose
Kotlin Usage
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.inputfield.Ux4gAadhaarInputField
import com.ux4g.designsystemv1.components.inputfield.Ux4gInputFieldSize
@Composable
fun AadhaarVerificationScreen() {
var aadhaarInput by remember { mutableStateOf("") }
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Ux4gAadhaarInputField(
value = aadhaarInput,
onValueChange = { formatted ->
aadhaarInput = formatted
},
label = "Label",
placeholder = "XXXX XXXX XXXX",
caption = "Description",
showMaskToggle = true,
size = Ux4gInputFieldSize.Medium,
modifier = Modifier.fillMaxWidth()
)
}
}Parameters
Ux4gAadhaarInputField Props
| Prop | Type | Description | Default |
|---|---|---|---|
value * | String | Raw or formatted 12-digit Aadhaar string. | — |
onValueChange * | (String) -> Unit | Callback providing the formatted XXXX XXXX XXXX string. | — |
modifier | Modifier | Compose layout modifier applied to the outer container. | Modifier |
size | Ux4gInputFieldSize | Height variant: Small (32dp), Medium (40dp), Large (48dp), XL (56dp). | Ux4gInputFieldSize.Medium |
status | Ux4gInputFieldStatus | Status state override. Automatically resolves to Success or Error upon 12 digits. | Ux4gInputFieldStatus.Default |
label | String? | Header title label. | "Aadhaar Number" |
required | Boolean | Displays required red asterisk when true. | false |
placeholder | String? | Placeholder displayed when field is empty. | "XXXX XXXX XXXX" |
caption | String? | Helper or error caption text below input. | "Enter your 12-digit Aadhaar number" |
showMaskToggle | Boolean | When true, renders an interactive eye icon (Visibility/VisibilityOff) to toggle digit masking. | false |
isMasked | Boolean? | Controlled masking state override. When null, managed internally. | null |
onMaskChange | ((Boolean) -> Unit)? | Callback triggered when the user taps the mask toggle icon. | null |
maskChar | Char | Character used to mask digits (e.g. 'X' or '•'). | 'X' |
leadingIcon | Any? | Icon placed at start (ImageVector, Ux4gIcon, or drawable resource Int). | null |
trailingIcon | Any? | Custom trailing icon override. Replaces mask toggle when provided. | null |
onTrailingIconPressed | (() -> Unit)? | Click handler for trailing icon. | null |
enabled | Boolean | Interactive state. | true |
readOnly | Boolean | When true, value cannot be edited. | false |
style | TextStyle? | Custom text style override for typed text. | null |
labelStyle | TextStyle? | Custom text style override for label. | null |
placeholderStyle | TextStyle? | Custom text style override for placeholder. | null |
captionStyle | TextStyle? | Custom text style override for caption. | null |
Verhoeff Validation Utility
Ux4gAadhaarInputField exposes standalone helper utilities for programmatic formatting and checksum validation:
// Validate Aadhaar number programmatically
val isValid = Ux4gAadhaarInputField.validateAadhaar("999941057058") // Returns true
// Format raw 12 digits to grouped string
val formatted = Ux4gAadhaarInputField.formatAadhaar("999941057058") // Returns "9999 4105 7058"