OTPVerificationKMP
1.2.0indexedLightweight, 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.
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 shapesdependencyResolutionManagement {
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
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
OtpTextField and connect to your backend| 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). |
Surfaced from shared tags and platforms — no rankings paid for.