OTP Text Field

OTP TextField

A specialized text input component for one-time passwords and verification codes.


Installation

./gradlew lumo --add OTPTextField

Usage

Basic OTP TextField

val otpState = rememberOtpState(length = 4)
 
OTPTextField(
    state = otpState,
    onComplete = { code ->
        // Handle completed OTP
    }
)

OTP TextField Types

// Filled OTP TextField
OTPTextField(
    state = otpState,
    onComplete = { code ->
        // Handle completed OTP
    }
)
 
// Outlined OTP TextField
OutlinedOTPTextField(
    state = otpState,
    onComplete = { code ->
        // Handle completed OTP
    }
)
 
// Underlined OTP TextField
UnderlinedOTPTextField(
    state = otpState,
    onComplete = { code ->
        // Handle completed OTP
    }
)

API Documentation

OTP TextField Types

ComponentDescription
OTPTextFieldBasic filled style OTP input
OutlinedOTPTextFieldOTP input with outlined style
UnderlinedOTPTextFieldOTP input with underline style

Parameters

ParameterTypeDefaultDescription
modifierModifierModifierModifier for the component
stateOTPStaterememberOtpStateState holder for OTP input
enabledBooleantrueWhether the input is enabled
readOnlyBooleanfalseWhether the input is read-only
isErrorBooleanfalseWhether to show error state
autoFocusBooleantrueWhether to focus first field
textStyleTextStyletypography.h3Text style for input
colorsOTPTextFieldColorsdefaultsColors for different states
visualTransformationVisualTransformationNoneTransform displayed text
onComplete(String) -> Unit{}Callback when OTP is complete

OTPState

Use rememberOtpState to create and remember OTP state:

val otpState = rememberOtpState(
    length = 4 // Number of OTP digits
)

Properties

PropertyTypeDescription
codeStringCurrent OTP value
lengthIntNumber of OTP digits
isComplete()() -> BooleanWhether all digits are filled