SecurityCodeTextField
A PCI-compliant security code input component for entering card CVV/CVC codes.
This component provides a secure input field for card security codes, with automatic formatting and validation. It supports both 3-digit (CVV) and 4-digit (CVC) security codes, with real-time feedback through events for validation and input state changes.
The component integrates with PCIFieldState for secure input management and provides events through SecurityCodeTextFieldEvent for handling focus changes, input completion, and length changes.
Features:
PCI-compliant input handling
Automatic digit validation
Configurable security code length
Real-time input state feedback
Customizable appearance and behavior
Example usage:
val state = rememberPCIFieldState()
SecurityCodeTextField(
state = state,
onEvent = { event ->
when (event) {
is SecurityCodeTextFieldEvent.OnInputFilled -> {
// Handle input completion
}
is SecurityCodeTextFieldEvent.OnLengthChanged -> {
// Update progress indicator
}
is SecurityCodeTextFieldEvent.OnFocusChanged -> {
// Show/hide security code hint
}
}
},
securityCodeSize = 3, // For 3-digit CVV
textStyle = MaterialTheme.typography.bodyLarge,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
)
Parameters
Modifier to customize the style and behavior of the field
A PCIFieldState object that manages the secure input data
Callback triggered for field events (focus changes, input completion, length changes)
Maximum number of digits allowed (typically 3 or 4)
Controls whether the field is interactive
Controls whether the field is editable
Composable for adding decorative elements around the text field
Text style applied to the input content
Configuration for the software keyboard
Brush applied to customize the cursor appearance
Visual transformations applied to the input text