KPInputOTPField

fun KPInputOTPField(style: InputOTPFieldStyle, otp: String, onValueChange: (String) -> Unit, modifier: Modifier = Modifier, otpLength: Int = DEFAULT_OTP_LENGTH, enabled: Boolean = true, hint: String? = null, errorText: String? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() })

A Composable function for creating an OTP (One-Time Password) input field with custom styling and behavior. This component handles the input of a fixed-length OTP and includes error display and interaction handling.

Parameters

style

The styling to be applied to the OTP input field. This includes properties like background color, border color, text color, etc.

otp

The initial OTP value to be displayed in the input field. This value initializes the internal state of the component.

onValueChange

A callback function invoked whenever the OTP value changes. This function receives the updated OTP as a parameter.

modifier

Modifier to apply to the root container of the input field. This parameter is optional and defaults to an empty Modifier.

otpLength

The length of the OTP input. This parameter defaults to DEFAULT_OTP_LENGTH. The input field will only accept this many characters.

enabled

A boolean flag indicating whether the input field is enabled or disabled. When disabled, the input field is not interactive. This parameter defaults to true.

hint

Optional hint text displayed below the input field when there is no error. This hint is shown only if it is not null.

errorText

Optional error message displayed below the input field. This message is shown only when the field is enabled and the errorText is not null.

interactionSource

The interaction source for tracking focus and other interaction states. This parameter is optional and defaults to a newly remembered instance of MutableInteractionSource.