Package-level declarations
Types
Colors of an OTP button. content should have at least 4.5:1 contrast against container (WCAG 1.4.3); violations are logged and listed in contrastWarnings, never thrown, so brand colors remain usable. The disabled pair is exempt from WCAG contrast requirements.
Colors of an OTP button, created with OtpButtonDefaults.colors. content should have at least 4.5:1 contrast against container (WCAG 1.4.3); violations are logged once and listed in contrastWarnings, never thrown, so brand colors remain usable. The disabled pair is exempt.
Default styles for OtpVerifyButton and OtpResendButton.
Default styles for OtpVerifyButton and OtpResendButton. From Swift, call for example OtpButtonDefaults.shared.style().
Style of OtpVerifyButton and OtpResendButton, created with OtpButtonDefaults.style. minHeight is raised to 48dp. A disabled button always draws at least a 1dp border so its state is not shown by color alone. colors null (the default) follows the system light or dark theme; pass OtpButtonDefaults.colors or OtpButtonDefaults.darkColors to force one.
Style of OtpVerifyButton and OtpResendButton, created with OtpButtonDefaults.style. minHeight is in points at the default text size, scales with Dynamic Type, and is raised to
Characters an OtpState.code may contain.
WCAG contrast checks shared by the Android and iOS components.
WCAG contrast requirement that a color pair is checked against.
Remaining resend time, passed to OtpResendAccessibility.countdownDescription so hosts can localize with plural rules.
One-time-code input built on UIKit. Visually it is a row of cells; for VoiceOver and Voice Control it is one text field (the cells, separators, placeholder, and error text are not accessibility elements). Embed view in SwiftUI with a UIViewRepresentable and keep this object alive, for example in the coordinator.
Required, localized accessibility text for an OTP field. There are deliberately no defaults so the component cannot be shown without it.
Colors of an OtpField, created with OtpFieldDefaults.colors. Checked pairs (opaque colors only; masked OtpMask.FilledCell cells use the border colors):
Colors of an OtpField, created with OtpFieldDefaults.colors. Use dynamic colors (the defaults are) so dark mode and Increase Contrast keep working. Checked pairs, resolved for the trait collection in use (opaque colors only; masked OtpMask.FilledCell cells use the border colors):
Default styles for OtpField.
Default styles for OtpField. From Swift, call for example OtpFieldDefaults.shared.style(); Kotlin default arguments are not visible to Swift, so the zero-argument functions return the defaults.
Visual style of an OtpField.
Visual style of an OtpField.
A multi-digit input (paste, autofill, keyboard suggestion) that was rejected because it did not contain exactly expectedDigitCount digits. Only the counts are available, never the digits, so they cannot end up in logs. A rejection usually means that the configured OtpLength differs from the code length of the host's backend.
Result of OtpState.withInput.
Visual masking of entered characters. Masking also switches the Android keyboard to a password keyboard, marks the field as a password for screen readers, and blocks copy, so visual and assistive-technology privacy stay consistent. Entries may be added in future versions; handle unknown values with an else branch.
Progress of the entered code, passed to OtpFieldAccessibility.progressDescription so hosts can localize with plural rules. A value object rather than primitive lambda parameters so the callback stays idiomatic when called from Swift.
Required, localized accessibility text for an OTP resend button.
"Resend code" button with a countdown. The host owns the timer and sets secondsRemaining; the button is disabled while it is above zero. The countdown text is the visible text and therefore also the accessible name (WCAG 2.5.3 Label in Name). There is no per-second announcement; verify the VoiceOver behavior on a device.
Required, localized accessibility text for an OTP verify button; label is also the visible text.
Button that verifies a complete code. It is enabled only while state is complete and isEnabled is true. The host owns verification: onVerify receives the code and should not also be triggered by OtpField.onComplete for the same code unless it de-duplicates. Use the same alignment as OtpField to keep them aligned. The visible text is also the accessible name. Embed view in SwiftUI with a UIViewRepresentable and keep this object alive.
Properties
Saves an OtpState for rememberSaveable, so a partly entered code survives configuration changes and process death:
Functions
One-time-code input that exposes a single logical text field to screen readers while drawing the digits as decorative cells (cells, group separators and placeholders are not in the accessibility tree).
"Resend code" button with a countdown. The host owns the timer and passes secondsRemaining; the button is disabled while it is above zero. The remaining time is the button text, which is also its accessible name (WCAG 2.5.3 Label in Name). There is no live region and no per-second announcement; verify the screen-reader behaviour on a device.
Button that verifies a complete code. It is enabled only while state is complete and enabled is true. The host owns verification: onVerify receives the code and should not also be triggered by onComplete of OtpField for the same code unless it de-duplicates. Pass the same alignment as OtpField to keep them aligned.