Skip to contentKino
Skip to Content

Input OTP

A one-time code in separate boxes, where each character rises into its box as it is typed or pasted.

npx shadcn add https://kinoui.com/r/input-otp.json
Share on

Examples

We sent it to maya@acme.com.

Default

Each digit rises into its box as it is typed, and a whole code can be pasted.

It’s 428 913 in this example.

Checked

Check the code in onValueComplete, keep it readOnly while you do, and show a wrong code as the field’s error.

Paste “ab12 cd34” and the space goes.

Alphanumeric

For recovery codes, take letters too and normalise them as they arrive.

Installation

npx shadcn@latest add https://kinoui.com/r/input-otp.json
Files
lib/refs.tslib/reduce-motion.tscomponents/kino/input.tsxcomponents/kino/separator.tsxcomponents/kino/input-otp.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

InputOTP

PropTypeDefaultDescription
lengthnumberNoneHow many characters the code has.
valuestringNoneThe code, when you hold the state.
onValueChange(value, details) => voidNoneCalled when the code changes.
onValueComplete(value, details) => voidNoneCalled when every box is filled.
validationType'numeric''alpha''alphanumeric''none''numeric'Which characters it takes; others are dropped.
maskbooleanfalseShows a dot for each character, as a password does.

CSS variables

VariableSet it onDefaultDescription
--input-otp-riseInputOTP, or <body>0.375remHow far each character rises into its box.

Accessibility

  • Every box takes the field’s label, and each after the first adds where it is.
  • Arrow keys and Backspace move between boxes, and a pasted code fills them all.
  • The first box asks the browser to fill a one-time code from a message.
  • While a code is checked, keep it readOnly, not disabled, so focus stays in it.
  • When the system asks for less motion, characters only fade in.