Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Apple docs
FormsApple

Input OTP

Enter numeric verification codes with native paste and autofill integration.

Public APILumenInputOTPApple / SwiftUISwift product: LumenUI

Apple availability

Supported native targets

Import LumenUI in the target that uses this component. iPad support follows the iOS package baseline and uses native iPad layout behavior.

iPhone · iOS 16+iPad · iPadOS 16+Mac · macOS 13+Apple Vision · visionOS 1+

Native example

Use Input OTP

The application verifies codes and owns submission. Normalize localized digit input into ASCII; reject invalid or excess input without truncating. Never send or persist credentials from the component.

Input OTP rendered in the iPhone simulator Lumen playground
Captured exampleiPhone simulator
swift
import LumenUI
import SwiftUI

struct VerificationCode: View {
    @State private var code = ""
    var body: some View {
        LumenInputOTP("Verification code", text: $code, length: 6,
            description: "Enter or paste six digits")
    }
}

Reference

Public API

The primary shared and platform-specific options exposed by LumenInputOTP.

APIValues or typeDefaultDescription
_ label / textString / Binding<String>RequiredControls at most length ASCII digits; localized edits normalize to ASCII.
lengthInt6Accepts code lengths from one through twelve.
maskedBoolfalseHides displayed digits.
onComplete(String) -> VoidEmpty closureReports a newly completed edit; the host verifies and submits.
description / errorMessageString?nilProvides localized supporting copy or host validation.
readOnly / .disabled(...)BoolfalseBlocks editing; disabled state comes from the SwiftUI environment.

Native behavior

Design and accessibility

When to use it

The application verifies codes and owns submission. Normalize localized digit input into ASCII; reject invalid or excess input without truncating. Never send or persist credentials from the component.

Accessibility

Uses one native input for paste, selection, deletion, and SMS code autofill; supports errors and optional masking.

Shared component

Available on other platforms

React NativeAndroid / Compose
Apple docsSwiftUI package