Skip to main content
Version: latest
Works everywhere

InputOtp works in both server and client environments. Always use the standard import (e.g. @prokodo/ui/input-otp) — the library detects the runtime automatically.

InputOTP

InputOTP renders a segmented one-time password input. Each digit occupies its own input box, and focus advances automatically as the user types.

Live demo →

Overview

import { InputOTP } from "@prokodo/ui/input-otp"
;<InputOTP
length={6}
label="Verification code"
onComplete={code => verifyCode(code)}
/>

Import

import { InputOTP } from "@prokodo/ui/input-otp"

CSS:

import "@prokodo/ui/input-otp.css"

Props

PropTypeDefaultRequiredDescription
namestringHidden input name for form submission.
lengthnumber6Number of OTP digit inputs.
labelstringGroup label text.
groupLabelstringAccessible group label for the OTP fieldset.
groupInstructionstringScreen-reader instruction text for the group.
disabledbooleanfalseDisable all digit inputs.
errorTextstringError message shown below the inputs.
onChange(value: string) => voidCalled with the combined value as each digit is entered.
classNamestringCSS class on root element.

See src/components/inputOTP/InputOTP.model.ts for the full InputOTPProps type.


Design Tokens

Customise InputOTP via CSS custom properties on :root or a scoped ancestor.

TokenDefaultDescription
--pk-otp-gapvar(--pk-space-sm)Gap between OTP cells
--pk-otp-cell-size2.75remWidth and height of each cell
--pk-otp-cell-radiusvar(--pk-radius-pill)Cell corner radius
--pk-otp-gradient-fromvar(--pk-color-brand)Active-cell gradient start
--pk-otp-gradient-tovar(--pk-color-accent)Active-cell gradient end

WCAG 2.2 Status

CriterionNameStatusNote
1.3.1Info and Relationships (A)✅ FulfilledSemantic structure (headings, lists, labels, landmarks) must be conveyed programmatically via HTML or ARIA.
1.3.5Identify Input Purpose (AA)🔍 Manual reviewForm fields collecting personal data must expose their purpose via the HTML autocomplete attribute.
2.1.1Keyboard (A)✅ FulfilledAll functionality must be operable via keyboard alone, without requiring specific timing.
2.4.7Focus Visible (AA)🔍 Manual reviewA visible keyboard focus indicator must be present on every interactive element. Verify against the applied product theme.
3.3.2Labels or Instructions (A)✅ FulfilledEvery form input requires a programmatically associated label or a visible instruction.
3.3.7Redundant Entry (A)🔍 Manual reviewInformation already entered in the same session/process must not be required again unless it serves a distinct purpose.
3.3.8Accessible Authentication (Min.) (AA)🔍 Manual reviewA cognitive function test (e.g. CAPTCHA, memory recall) must not be the sole authentication mechanism.
4.1.2Name, Role, Value (A)✅ FulfilledName, role, and state of all interactive UI components must be programmatically determinable via native HTML semantics or ARIA.

Test coverage: 2 jest-axe assertion(s) across 1 test file(s) · 3 ARIA attribute occurrence(s) in source scan. Criteria marked 🔍 require manual verification in the final product integration and theme context.

Storybook

👉 Open InputOTP in Storybook


Source

src/components/inputOTP/InputOTP.model.ts