UX4G Logo
Components

Input Field

Standard Text Input, Password Field, Status States, Prefix/Postfix Affixes, Icons, Read-Only, Aadhaar Number, and PAN Input Field components

The UX4G Input Field component family provides high-accessibility text entry controls with comprehensive support for validation states, password toggles, affixes, leading/trailing icons, read-only mode, and specialized Indian citizen identity inputs (Aadhaar & PAN).

Import from com.ux4g.designsystemv1.components.inputfield.*.


Interactive Previews

1. Default Input Field

Standard text entry field with header label, placeholder, and helper caption.

Ux4gInputField (Default)Jetpack Compose
UX4G Default Input Field Preview

2. Validation & Status States (All Statuses)

Dynamic validation states with color-coded borders and status caption icons for Error, Default/Info, Success, Warning, and Disabled states.

Ux4gInputField (All Status States)Jetpack Compose
UX4G Input Field All Status Preview

3. Password Field with Visibility Toggle

Built-in masked password input with automatic eye show/hide icon toggle.

Ux4gInputField (Password Field)Jetpack Compose
UX4G Password Input Field Preview

4. Leading & Trailing Icons

Input fields supporting start icon, end action icon, or both icons simultaneously.

Ux4gInputField (With Icons)Jetpack Compose
UX4G Input Field with Icons Preview

5. Prefix & Postfix Affixes

Pre-formatted currency symbols, URL protocols, and domain extensions placed inside the input container.

Ux4gInputField (Prefix & Postfix)Jetpack Compose
UX4G Prefix and Postfix Input Field Preview

6. Read-Only Field

Non-editable input field maintaining standard text selection and copy capabilities.

Ux4gInputField (Read-Only)Jetpack Compose
UX4G Read Only Input Field Preview

Kotlin Usage

Citizen Registration Form Example
import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Badge
import androidx.compose.material.icons.filled.CreditCard
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.Person
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.inputfield.*

@Composable
fun CitizenFormExample() {
    var fullName by remember { mutableStateOf("") }
    var password by remember { mutableStateOf("") }
    var aadhaar by remember { mutableStateOf("") }
    var pan by remember { mutableStateOf("") }
    var monthlyIncome by remember { mutableStateOf("") }

    Column(
        modifier = Modifier
            .fillMaxWidth()
            .padding(16.dp),
        verticalArrangement = Arrangement.spacedBy(16.dp)
    ) {
        // 1. Text Field with Leading Icon
        Ux4gInputField(
            value = fullName,
            onValueChange = { fullName = it },
            label = "Full Name",
            required = true,
            placeholder = "Enter your full name",
            leadingIcon = Icons.Default.Person
        )

        // 2. Password Field
        Ux4gInputField(
            value = password,
            onValueChange = { password = it },
            label = "Account Password",
            required = true,
            placeholder = "Enter password",
            type = Ux4gInputFieldType.Password,
            leadingIcon = Icons.Default.Lock,
            showPasswordToggle = true
        )

        // 3. Aadhaar Auto-formatting (XXXX XXXX XXXX) with Verhoeff Validation
        Ux4gAadhaarInputField(
            value = aadhaar,
            onValueChange = { aadhaar = it },
            label = "Aadhaar Number",
            required = true,
            leadingIcon = Icons.Default.Badge
        )

        // 4. PAN Card Auto-uppercase & Regex Validation
        Ux4gPanInputField(
            value = pan,
            onValueChange = { pan = it },
            label = "PAN Card Number",
            required = true,
            leadingIcon = Icons.Default.CreditCard
        )

        // 5. Income with Currency Prefix
        Ux4gInputField(
            value = monthlyIncome,
            onValueChange = { monthlyIncome = it },
            label = "Monthly Income",
            placeholder = "0",
            prefixText = "₹",
            postfixText = ".00",
            type = Ux4gInputFieldType.Number
        )
    }
}

Parameters

1. Ux4gInputField Props

PropTypeDescriptionDefault
value *StringCurrent text value of the input field.—
onValueChange *(String) -> UnitCallback invoked when citizen types or modifies content.—
modifierModifierCompose layout modifier applied to the outer container.Modifier
sizeUx4gInputFieldSizeContainer height variant: Small (32dp), Medium (40dp), Large (48dp), XL (56dp).Ux4gInputFieldSize.Medium
typeUx4gInputFieldTypeInput type & keyboard configuration: Text, Password, Number, Email.Ux4gInputFieldType.Text
statusUx4gInputFieldStatusValidation visual state: Default, Success, Warning, Error.Ux4gInputFieldStatus.Default
labelString?Header title label displayed above the field.null
requiredBooleanWhen true, renders a red asterisk (*) next to the label.false
placeholderString?Placeholder text shown when the input field is empty.null
captionString?Explanatory helper or error description text below the input field.null
leadingIconAny?Icon placed at the start (ImageVector, Ux4gIcon, or drawable resource Int).null
trailingIconAny?Icon placed at the end (ImageVector, Ux4gIcon, or drawable resource Int).null
onTrailingIconPressed(() -> Unit)?Optional click callback for the trailing icon.null
prefixTextString?Static affix text anchored before the editable text (e.g. "₹" or "https://").null
postfixTextString?Static affix text anchored after the editable text (e.g. ".00" or ".com").null
trailingIconLabelAny?Optional info icon rendered adjacent to the label.null
enabledBooleanControls interactive enabled state and disabled styling.true
readOnlyBooleanWhen true, text cannot be edited but remains focusable and copyable.false
singleLineBooleanWhether input is single-line or expandable multiline.true
maxLinesIntMaximum lines allowed before vertical scrolling.1
maxLengthInt?Maximum character length limit.null
textAlignTextAlignText alignment within the input area.TextAlign.Start
showPasswordToggleBooleanWhen type is Password, controls rendering of the eye visibility toggle.true
styleTextStyle?Custom text style override for the typed text.null
placeholderStyleTextStyle?Custom text style override for placeholder.null
labelStyleTextStyle?Custom text style override for label.null
captionStyleTextStyle?Custom text style override for caption.null
backgroundColorColor?Custom container background color override.null
borderColorColor?Custom border color override.null
borderWidthDpCustom border width.1.dp
keyboardOptionsKeyboardOptions?Custom software keyboard options.null
keyboardActionsKeyboardActionsCustom software keyboard actions (Done, Next, Search).KeyboardActions.Default

2. Ux4gAadhaarInputField Props

PropTypeDescriptionDefault
value *StringRaw or formatted 12-digit Aadhaar number.—
onValueChange *(String) -> UnitFormats input into XXXX XXXX XXXX chunks and validates checksum.—
labelString?Label heading."Aadhaar Number"
placeholderString?Placeholder text."XXXX XXXX XXXX"
captionString?Guidance caption (auto-switches to validation error/success message)."Enter your 12-digit Aadhaar number"
sizeUx4gInputFieldSizeInput size variant.Ux4gInputFieldSize.Medium
statusUx4gInputFieldStatusStatus state override (automatically evaluated with Verhoeff algorithm).Ux4gInputFieldStatus.Default
requiredBooleanShows required asterisk.false
leadingIconAny?Icon at start.null
trailingIconAny?Icon at end.null
onTrailingIconPressed(() -> Unit)?Trailing icon click handler.null
enabledBooleanInteractive state.true
readOnlyBooleanNon-editable state.false

3. Ux4gPanInputField Props

PropTypeDescriptionDefault
value *String10-character alphanumeric PAN string.—
onValueChange *(String) -> UnitConverts input to uppercase and validates against standard PAN regex ([A-Z]{5}[0-9]{4}[A-Z]{1}).—
labelString?Label heading."PAN Card Number"
placeholderString?Placeholder text."ABCDE1234F"
captionString?Guidance caption (auto-switches on 10 valid/invalid characters)."Enter your 10-character PAN number"
sizeUx4gInputFieldSizeInput size variant.Ux4gInputFieldSize.Medium
statusUx4gInputFieldStatusStatus state override.Ux4gInputFieldStatus.Default
requiredBooleanShows required asterisk.false
leadingIconAny?Icon at start.null
trailingIconAny?Icon at end.null
onTrailingIconPressed(() -> Unit)?Trailing icon click handler.null
enabledBooleanInteractive state.true
readOnlyBooleanNon-editable state.false

4. Enums Reference

Ux4gInputFieldStatus

enum class Ux4gInputFieldStatus {
    Default,  // Standard neutral state with helper info
    Success,  // Green border and CheckCircle icon
    Warning,  // Orange border and Warning icon
    Error     // Red border and Error icon
}

Ux4gInputFieldType

enum class Ux4gInputFieldType {
    Text,      // Standard alphanumeric keyboard
    Password,  // Masked input with password toggle
    Number,    // Numeric keypad
    Email      // Email keypad with @ and domain shortcuts
}

Ux4gInputFieldSize

enum class Ux4gInputFieldSize(val height: Dp) {
    Small(32.dp),
    Medium(40.dp), // Default UX4G container height
    Large(48.dp),
    XL(56.dp)
}

On this page