
Lightweight, customizable OTP/PIN input component with features like auto SMS reading, animations, and styling control. Supports cross-platform use and smart states for seamless integration.
A lightweight & customizable OTP/PIN input component for Kotlin Multiplatform (Android, iOS, Desktop, JVM) built with Jetpack Compose.
β¨ Features auto SMS reading on Android, animations, adaptive spacing, box sizing, and full styling control.
RoundedBox, Circle, Underline shapesOtpTextField and connect to your backenddependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}commonMain {
dependencies {
implementation("io.github.atharvyadav22:otp-verification-kmp:1.1.0")
}
}β‘ Prefer the common
otp-verification-kmpin KMP projects. Use platform-specific only if your project is not multiplatform.
var otpValue by remember { mutableStateOf("") }
OtpTextField(
otpValue = otpValue,
onOtpValueChange = { otpValue = it },
otpLength = 6,
shape = OtpShape.RoundedBox,
spacing = 16.dp, // optional: custom spacing, null for default even spacing
verifyOtp = { enteredOtp -> enteredOtp == "123456" },
onSuccess = { /* β
OTP verified - perform navigation */ },
onError = { /* β Wrong OTP - show error or resend */ }
)π See full demo with multiple styles here: LibraryPreview.kt
| Parameter | Type | Description |
|---|---|---|
otpValue |
String |
Current OTP input. |
onOtpValueChange |
(String) -> Unit |
Called on OTP input change. |
otpLength |
Int |
Total number of OTP digits. |
verifyOtp |
suspend (String) -> Boolean |
Verification logic (backend/local). |
onSuccess |
() -> Unit |
Triggered when OTP is correct. |
onError |
() -> Unit |
Triggered when OTP is invalid. |
shape |
OtpShape |
UI shape β RoundedBox, Circle, Underline. |
textStyle |
TextStyle |
Custom font style. |
borderSize |
Dp |
Border thickness of each OTP box. |
boxSize |
Dp |
Width & height of each OTP box (optional, default 40.dp). |
spacing |
Dp? |
Optional horizontal spacing between boxes; defaults to evenly distributed if null. |
shakeMagnitude |
Float |
Magnitude of shake animation on OTP verification failure (optional). |
shakeDuration |
Int |
Duration of each shake animation movement in milliseconds (optional). |
shakeIterations |
Int |
Number of shake repetitions when OTP verification fails (optional). |
We follow Semantic Versioning (SemVer):
π All release tags & changelogs are available on GitHub Releases.
Copyright 2025 Atharv Yadav
Licensed under the Apache License, Version 2.0
A lightweight & customizable OTP/PIN input component for Kotlin Multiplatform (Android, iOS, Desktop, JVM) built with Jetpack Compose.
β¨ Features auto SMS reading on Android, animations, adaptive spacing, box sizing, and full styling control.
RoundedBox, Circle, Underline shapesOtpTextField and connect to your backenddependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}commonMain {
dependencies {
implementation("io.github.atharvyadav22:otp-verification-kmp:1.1.0")
}
}β‘ Prefer the common
otp-verification-kmpin KMP projects. Use platform-specific only if your project is not multiplatform.
var otpValue by remember { mutableStateOf("") }
OtpTextField(
otpValue = otpValue,
onOtpValueChange = { otpValue = it },
otpLength = 6,
shape = OtpShape.RoundedBox,
spacing = 16.dp, // optional: custom spacing, null for default even spacing
verifyOtp = { enteredOtp -> enteredOtp == "123456" },
onSuccess = { /* β
OTP verified - perform navigation */ },
onError = { /* β Wrong OTP - show error or resend */ }
)π See full demo with multiple styles here: LibraryPreview.kt
| Parameter | Type | Description |
|---|---|---|
otpValue |
String |
Current OTP input. |
onOtpValueChange |
(String) -> Unit |
Called on OTP input change. |
otpLength |
Int |
Total number of OTP digits. |
verifyOtp |
suspend (String) -> Boolean |
Verification logic (backend/local). |
onSuccess |
() -> Unit |
Triggered when OTP is correct. |
onError |
() -> Unit |
Triggered when OTP is invalid. |
shape |
OtpShape |
UI shape β RoundedBox, Circle, Underline. |
textStyle |
TextStyle |
Custom font style. |
borderSize |
Dp |
Border thickness of each OTP box. |
boxSize |
Dp |
Width & height of each OTP box (optional, default 40.dp). |
spacing |
Dp? |
Optional horizontal spacing between boxes; defaults to evenly distributed if null. |
shakeMagnitude |
Float |
Magnitude of shake animation on OTP verification failure (optional). |
shakeDuration |
Int |
Duration of each shake animation movement in milliseconds (optional). |
shakeIterations |
Int |
Number of shake repetitions when OTP verification fails (optional). |
We follow Semantic Versioning (SemVer):
π All release tags & changelogs are available on GitHub Releases.
Copyright 2025 Atharv Yadav
Licensed under the Apache License, Version 2.0