Kinetic OTP Input

A one-time-code field made of single cells. It advances as you type, accepts a pasted code and fires an event when it is full.

  • <kt-kinetic-otp>
  • Inputs
  • No framework

Kinetic OTP Input

The code

Copy the Kinetic OTP Input

Fastest: press Copy on the card above for one complete file. To build it into your own project, use the files below: the markup, the styles, this component’s script and the shared effects script (effects.js) that every component uses.

<kt-kinetic-otp label="Verification code" length="6"></kt-kinetic-otp>

<kt-kinetic-otp label="Backup code" length="8" mode="text" value="K4F9"></kt-kinetic-otp>

<kt-kinetic-otp label="PIN" length="4" mask value="1234" error></kt-kinetic-otp>

Attributes

NameWhat it doesDefault
lengthNumber of cells, 2 to 10.6
valueThe code entered so far.—
labelText above the cells.Verification code
mode"numeric" accepts digits only; "text" accepts letters and digits.numeric
maskPresent to hide the characters like a password.—
errorPresent to mark the code as wrong (red cells, aria-invalid).—
disabledPresent when the cells cannot be used.—
sfxSound-effect text when the code is complete.ピッ!

Keyboard and screen readers

  • The cells are grouped (role="group") under the label, and each has a name like "Digit 2 of 6".
  • Typing moves to the next cell; Backspace clears the cell, or steps back and clears the previous one when empty.
  • ArrowLeft and ArrowRight move between cells; Home and End jump to the first and last.
  • Pasting a full code fills every cell; the first cell asks the browser for one-time-code autofill.
  • Fires change with { value, complete } and a separate complete event once every cell is filled; "Code complete" is announced politely.

Styling variables

Every look is a CSS variable: --kt-accent, --kt-accent-ink, --kt-radius-btn, --kt-surface-radius, --kt-surface-bg, --kt-border-w, --kt-comp-shadow and --font-sans. The copied file sets them all from your choices.

FAQ

Kinetic OTP Input: questions answered

How do I use the Kinetic OTP Input?

Press Copy on the card to get a complete HTML file, or copy the HTML, CSS and JavaScript tabs into your own page. In your markup the element is written as <kt-kinetic-otp>.

Which attributes does <kt-kinetic-otp> accept?

length, value, label, mode, mask, error, disabled, sfx. Each one is described in the attributes table on this page.

Is the Kinetic OTP Input accessible?

The cells are grouped (role="group") under the label, and each has a name like "Digit 2 of 6". Typing moves to the next cell; Backspace clears the cell, or steps back and clears the previous one when empty. ArrowLeft and ArrowRight move between cells; Home and End jump to the first and last. Pasting a full code fills every cell; the first cell asks the browser for one-time-code autofill. Fires change with { value, complete } and a separate complete event once every cell is filled; "Code complete" is announced politely.

Can I change the Kinetic OTP Input colors, corners and font?

Yes. Use the options on this page: accent color, border radius, background, border, shadow and Google font. The copied code already contains your choices, and every one of them is a CSS variable you can edit later.