Dissipate Input

An email input with a particle dissipation effect that transitions to OTP verification.

Jan 12, 2025

Type an email and press Enter to see the text dissolve into particles, then enter the OTP.

Inspired by @raunofreiberg.

Features

  • Canvas-based particle dissipation effect
  • Email validation with error states
  • Smooth transition to OTP input
  • Auto-focus on OTP field
  • Shake animation for errors
  • Customizable placeholders and callbacks

Usage

Full Email → OTP Flow

import DissipateInput from "./dissipate-input";
 
<DissipateInput
  emailPlaceholder="sup@husnainfareed.dev"
  otpPlaceholder="123456"
  otpHelperText="check your email for a one-time password"
  onEmailSubmit={(email) => {
    // Send OTP to email
    sendOTP(email);
  }}
  onOtpSubmit={(otp) => {
    // Verify OTP
    verifyOTP(otp);
  }}
/>

Email Only (No OTP)

<DissipateInput
  showOtpStep={false}
  onEmailSubmit={(email) => {
    // Handle email submission
    subscribeToNewsletter(email);
  }}
/>

Standalone Dissipation Effect

import { DissipateTextEffect } from "./dissipate-input";
 
<DissipateTextEffect
  value="Hello World"
  width={800}
  height={120}
  fontSize={24}
  color="#FFFFFF"
  sweepSpeed={8}
  onDone={() => console.log("Animation complete")}
/>

Props

DissipateInput

PropTypeDefaultDescription
emailPlaceholderstring"sup@husnainfareed.dev"Email input placeholder
otpPlaceholderstring"123456"OTP input placeholder
otpHelperTextstring"check your email..."Helper text shown on OTP step
showOtpStepbooleantrueShow OTP input after email
onEmailSubmit(email: string) => void-Email submission callback
onOtpSubmit(otp: string) => void-OTP submission callback
classNamestring""Additional CSS classes

DissipateTextEffect

PropTypeDefaultDescription
valuestringrequiredText to dissipate
widthnumberrequiredCanvas width (use 2x for retina)
heightnumberrequiredCanvas height (use 2x for retina)
fontSizenumber24Font size in pixels
fontFamilystring"PP Neue Montreal"...Font family
colorstring"#FFFFFF"Text color
sweepSpeednumber8Dissipation speed (px/frame)
onReady() => void-Called when particles are ready
onDone() => void-Called when animation completes
Plan B - The Chef Arc