UX4G Logo
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") or Ux4gInputFieldStatus.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
UX4G Aadhaar Input Field Preview

Kotlin Usage

AadhaarVerificationScreen.kt
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

PropTypeDescriptionDefault
value *StringRaw or formatted 12-digit Aadhaar string.—
onValueChange *(String) -> UnitCallback providing the formatted XXXX XXXX XXXX string.—
modifierModifierCompose layout modifier applied to the outer container.Modifier
sizeUx4gInputFieldSizeHeight variant: Small (32dp), Medium (40dp), Large (48dp), XL (56dp).Ux4gInputFieldSize.Medium
statusUx4gInputFieldStatusStatus state override. Automatically resolves to Success or Error upon 12 digits.Ux4gInputFieldStatus.Default
labelString?Header title label."Aadhaar Number"
requiredBooleanDisplays required red asterisk when true.false
placeholderString?Placeholder displayed when field is empty."XXXX XXXX XXXX"
captionString?Helper or error caption text below input."Enter your 12-digit Aadhaar number"
showMaskToggleBooleanWhen true, renders an interactive eye icon (Visibility/VisibilityOff) to toggle digit masking.false
isMaskedBoolean?Controlled masking state override. When null, managed internally.null
onMaskChange((Boolean) -> Unit)?Callback triggered when the user taps the mask toggle icon.null
maskCharCharCharacter used to mask digits (e.g. 'X' or '•').'X'
leadingIconAny?Icon placed at start (ImageVector, Ux4gIcon, or drawable resource Int).null
trailingIconAny?Custom trailing icon override. Replaces mask toggle when provided.null
onTrailingIconPressed(() -> Unit)?Click handler for trailing icon.null
enabledBooleanInteractive state.true
readOnlyBooleanWhen true, value cannot be edited.false
styleTextStyle?Custom text style override for typed text.null
labelStyleTextStyle?Custom text style override for label.null
placeholderStyleTextStyle?Custom text style override for placeholder.null
captionStyleTextStyle?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"

On this page