Skip to content
FormsInteractive playground

InputOTP

A verification code split into slots.

Preparing the playground…
Text and Markdown example
InputOTP · Example
1<InputOTP maxLength={6} aria-label="Verification code"><InputOTPGroup>{[0,1,2,3,4,5].map(index => <InputOTPSlot key={index} index={index} />)}</InputOTPGroup></InputOTP>
Read documentation in Markdown

How to use it

Set maxLength and an index for each slot. Your server must validate the code; the component only collects input.

Import

React / Next.js
1import { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator } from "@kivora/nextjs";

Interactive examples run inside a component with "use client". The playground's Copy button includes the imports needed for the current example.

API reference 0.2.0

Types from the installed published version, including component properties and common HTML attributes. “Optional” does not imply a default value; omitting a property lets the component decide.

PropertyTypeDescription
childrenRequiredundefined | ReactNodeContent or child elements of the component.
maxLengthRequirednumberMaximum number of characters.
altstringAlternative text for the image.
aria-labelstringAccessible name of the control.
autoCompleteHTMLInputAutoCompleteAttributeTell the browser which autocomplete type to use.
checkedbooleanControlled selection state.
classNamestringAdditional CSS classes to customize the element.
containerClassNamestringCSS classes for the specified element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
maxstring | numberMaximum allowed value.
minstring | numberMinimum allowed value.
namestringName used to identify the control in forms.
noncestringConfigures nonce. The type describes the supported values and structure.
noScriptCSSFallbackstring | nullConfigures noScriptCSSFallback. The type describes the supported values and structure.
onChange((newValue: string) => unknown)Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLInputElement>Action performed when the element is activated.
onComplete((...args: any[]) => unknown)Callback when input or an operation is complete.
onSubmitSubmitEventHandler<HTMLInputElement>Form submission event.
pasteTransformer((pasted: string) => string)Configures pasteTransformer. The type describes the supported values and structure.
placeholderstringShort hint displayed when there is no value.
pushPasswordManagerStrategy"none" | "increase-width"Configures pushPasswordManagerStrategy. The type describes the supported values and structure.
renderInputOTPRenderFn | undefinedConfigures render. The type describes the supported values and structure.
requiredbooleanIndicates that a value is required.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
srcstringResource path or URL.
stepstring | numberIncrement between values.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
textAlign"center" | "left" | "right"Configures textAlign. The type describes the supported values and structure.
titlestringTitle or supplementary information.
typeHTMLInputTypeAttributeOperation type or mode; values depend on the component.
valuestringControlled value. Update it from the change callback.

Subcomponents and composition

Review each component's properties and published declaration. Native and accessibility attributes are inherited from the element specified by its type.

InputOTP35 properties
InputOTP · TypeScript
1InputOTP: React.ForwardRefExoticComponent<InputOTPProps & React.RefAttributes<HTMLInputElement>>
InputOTPGroup13 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
InputOTPGroup · TypeScript
1InputOTPGroup: React.ForwardRefExoticComponent<InputOTPGroupProps & React.RefAttributes<HTMLDivElement>>
InputOTPSlot14 properties
PropertyTypeDescription
indexRequirednumberConfigures index. The type describes the supported values and structure.
aria-labelstringAccessible name of the control.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
InputOTPSlot · TypeScript
1InputOTPSlot: React.ForwardRefExoticComponent<InputOTPSlotProps & React.RefAttributes<HTMLDivElement>>
InputOTPSeparator13 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
InputOTPSeparator · TypeScript
1InputOTPSeparator: React.ForwardRefExoticComponent<InputOTPSeparatorProps & React.RefAttributes<HTMLDivElement>>
API generated from @kivora/nextjs 0.2.0View package