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>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.
| Property | Type | Description |
|---|---|---|
childrenRequired | undefined | ReactNode | Content or child elements of the component. |
maxLengthRequired | number | Maximum number of characters. |
alt | string | Alternative text for the image. |
aria-label | string | Accessible name of the control. |
autoComplete | HTMLInputAutoCompleteAttribute | Tell the browser which autocomplete type to use. |
checked | boolean | Controlled selection state. |
className | string | Additional CSS classes to customize the element. |
containerClassName | string | CSS classes for the specified element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
disabled | boolean | Disable interaction with the control. |
id | string | Element identifier; associates labels and descriptions. |
max | string | number | Maximum allowed value. |
min | string | number | Minimum allowed value. |
name | string | Name used to identify the control in forms. |
nonce | string | Configures nonce. The type describes the supported values and structure. |
noScriptCSSFallback | string | null | Configures 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. |
onClick | MouseEventHandler<HTMLInputElement> | Action performed when the element is activated. |
onComplete | ((...args: any[]) => unknown) | Callback when input or an operation is complete. |
onSubmit | SubmitEventHandler<HTMLInputElement> | Form submission event. |
pasteTransformer | ((pasted: string) => string) | Configures pasteTransformer. The type describes the supported values and structure. |
placeholder | string | Short hint displayed when there is no value. |
pushPasswordManagerStrategy | "none" | "increase-width" | Configures pushPasswordManagerStrategy. The type describes the supported values and structure. |
render | InputOTPRenderFn | undefined | Configures render. The type describes the supported values and structure. |
required | boolean | Indicates that a value is required. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
src | string | Resource path or URL. |
step | string | number | Increment between values. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
textAlign | "center" | "left" | "right" | Configures textAlign. The type describes the supported values and structure. |
title | string | Title or supplementary information. |
type | HTMLInputTypeAttribute | Operation type or mode; values depend on the component. |
value | string | Controlled 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
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
InputOTPGroup · TypeScript
1InputOTPGroup: React.ForwardRefExoticComponent<InputOTPGroupProps & React.RefAttributes<HTMLDivElement>>InputOTPSlot14 properties
| Property | Type | Description |
|---|---|---|
indexRequired | number | Configures index. The type describes the supported values and structure. |
aria-label | string | Accessible name of the control. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
InputOTPSlot · TypeScript
1InputOTPSlot: React.ForwardRefExoticComponent<InputOTPSlotProps & React.RefAttributes<HTMLDivElement>>InputOTPSeparator13 properties
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
InputOTPSeparator · TypeScript
1InputOTPSeparator: React.ForwardRefExoticComponent<InputOTPSeparatorProps & React.RefAttributes<HTMLDivElement>>API generated from @kivora/nextjs 0.2.0View package