OTP input

OTP input is a neobrutalist React component from Cruise UI. 4 or 6 boxes for a one-time code, with paste, error and a resend countdown. Install it with npx shadcn@latest add @cruiseui/otp-input.

Install

Terminal

npx shadcn@latest add @cruiseui/otp-input

First time? Installation shows the one-off components.json setup (the @cruiseui registry) and how to turn the theme on.

Example

Corners

Enter the 6-digit code we sent to 0803 *** 4567

When to use it

When to use

A code sent by SMS or email to sign in or confirm a payment.

When not to

Passwords or PINs people chose themselves (use an Input).

Props

CruiseOtpInput

PropTypeDefaultDescription
length?4 | 66—
labelstring—The instruction above the boxes; it labels the group.
onComplete?((code: string) => void)——
error?string—Shown below the boxes with an icon; turns the borders --danger.
resendAfter?number30Seconds before "Resend code" is enabled; omit onResend to hide it.
onResend?(() => void)——
className?string——

Accessibility

  • inputmode="numeric" and autocomplete="one-time-code" on the first box, so phones offer the SMS code.
  • Each box is labelled "Digit 1 of 6"…; errors are announced with role="alert".