‮Skip to content‬
uiify

OTP input

‮Input for one-time codes, with one slot per character.‬

‮Browsers‬
Chrome 123+Firefox 121+Safari 17.5+
‮Tier‬
2
‮Bundle compressed‬
1.53 kB
‮Forced layout budget‬
0 ms
‮Axe budget‬
0
‮SSR compatible‬
‮Yes‬
‮Published contract‬
‮Test harness‬

‮Playground‬

OTP Input

‮Default‬

‮API‬

OtpInput.Root

‮Prop‬‮Type‬‮Default‬‮Description‬
valuestring—‮Current code, making the field controlled.‬
defaultValuestring""‮Starting code for the uncontrolled field.‬
onValueChange(value: string) => void—‮Called with the code whenever it changes.‬
onComplete(value: string) => void—‮Called once the code reaches the configured length.‬
lengthnumber6‮Number of characters the code holds.‬
type"numeric" | "alphanumeric""numeric"‮Which characters are kept when typing or pasting.‬
maskbooleanfalse‮Hides the entered characters in the slots.‬
disabledbooleanfalse‮Disables the hidden input and sets the data-disabled attribute.‬
autoFocusbooleanfalse‮Focuses the hidden input when the field mounts.‬
idstring—‮Id applied to the rendered root element.‬
renderReactElement | ((props, state) => ReactElement)—‮Replace the rendered element while keeping behavior and accessibility wiring.‬

OtpInput.Slot

‮Prop‬‮Type‬‮Default‬‮Description‬
index*number—‮Position in the code this slot displays.‬
renderReactElement | ((props, state) => ReactElement)—‮Replace the rendered element while keeping behavior and accessibility wiring.‬

OtpInput.HiddenInput

‮Prop‬‮Type‬‮Default‬‮Description‬
autoFocusboolean—‮Focuses this input on mount, overriding the root setting.‬
renderReactElement | ((props, state) => ReactElement)—‮Replace the rendered element while keeping behavior and accessibility wiring.‬

‮Keyboard‬

‮Key‬‮Action‬
Tab‮Move focus to/from the control‬
Enter / Space‮Activate when focused (button-like controls)‬

‮Accessibility‬

‮Uses semantic HTML where possible. Inspect rendered markup in the playground — ARIA is added only when native elements are insufficient.‬

‮Styling hooks‬

data-disabled