Animated React form components

OTP code

A one time code card with split boxes and no confirm button. The last digit starts the check: the boxes ripple, then the card glides into a verified confirmation, or the boxes shake red and clear.

Forms, type, Motion

Install

npm i clsx motion tailwind-merge && curl -o components/otp-code.tsx https://motion-brew.com/r/otp-code.tsx

One self contained file for React and Tailwind CSS: otp-code.tsx. Or ask your AI agent to add it through the MCP server.

Usage

import { OtpCode } from "@/components/otp-code";

export default function Verify() {
  return (
    <OtpCode
      length={6}
      channel="email"
      destination={user.email}
      verify={async (code) => (await api.verifyCode(code)).ok}
      onVerified={() => router.push("/app")}
      onResend={() => api.sendCode()}
    />
  );
}

Props

PropTypeDefaultDescription
lengthnumber6Digits, 3 to 8
channel"email" \"phone""email"Changes the icon and the copy
destinationstringa sample addressWhere the code went
maskDestinationbooleantrueShows jo•••@lumen.app or +1 ••• ••• 0182
splitbooleantrueTwo groups of boxes (from 4 digits)
maskbooleanfalseDots instead of digits
resendAfternumber30Seconds before a new code can be sent
verify(code) => boolean \Promise<boolean>every code passesReturn true when the code is right
onVerified(code) => voidCalled once a code passes
onResend() => void \Promise<void>Called by Resend code
onContinue() => voidThe confirmation's main button
continueLabelstring"Continue"Its label
onRememberDevice(remember) => voidThe confirmation's Remember this device switch
autoFocusbooleanfalseFocus the boxes when the card scrolls into view; for a page that is only this step
classNamestringPlacement and width

More forms

  • Auth card: Sign in and sign up in one card.
  • File drop: A drag and drop uploader.
  • Voice prompt: An AI composer you can talk to.
  • Amount slider: Drag the grip thumb and the amount rolls like an odometer while the monthly payment works itself out.

All animated react form components