Love This UI? Help It Grow and Reach More Developers Worldwide — Check out

Retro Form

A dynamic, retro-styled form component for React and Next.js, featuring customizable fields, built-in validation, and a nostalgic design with Lucide icons and Tailwind CSS.

REGISTER

Join the Retro Club!

BASIC INFO

USERNAME *
EMAIL *

CONTACT INFO

PHONE NUMBER

SECURITY

PASSWORD *
CONFIRM PASSWORD *
GENDER

Usage

The RetroForm component is highly customizable and supports various field types (text, email, password, tel, date, select). Below is an example for a registration form:

Loading...

Props

PropTypeDefaultRequiredDescription
formType'register' | 'profile' | 'login'None (required)NoDefines the type of form, affecting default titles and required fields.
fieldsFieldConfig[][]NoArray of field objects with `name`, `type`, `label`, `placeholder`, `icon`, `options`, `required`, and optional `section` for grouping.
onSubmit(data: Record<string, string>) => voidNone (required)NoCallback function triggered on form submission with form data.
titlestringConditional: 'SIGN IN' (login), 'REGISTER' (register), 'UPDATE PROFILE' (profile)NoMain title of the form.
subtitlestringConditional: 'Welcome Back!' (login), 'Join the Retro Club!' (register), 'Update Your Info!' (profile)NoSubtitle text below the form title.
buttonTextstringConditional: 'LOGIN' (login), 'SUBMIT' (register/profile)NoText for the submit button.
showOTPbooleanfalseNoEnables OTP verification for the phone number field. Note: OTP functionality is a placeholder and requires integration with an external service (e.g., Twilio).

Field Config

PropTypeDefaultRequiredDescription
namestringNone (required)NoUnique identifier for the field.
type'text' | 'email' | 'password' | 'tel' | 'date' | 'select''text'NoField input type.
labelstringNone (required)NoDisplay label for the field.
placeholderstring`Enter ${label.toLowerCase()}`NoPlaceholder text for the input.
icon'user' | 'mail' | 'lock' | 'phone' | 'calendar' | 'mapPin' | React.ElementType'user'NoIcon to display with the field. Can be a predefined string or a custom React component.
options{ value: string; label: string }[]undefinedNoOptions for select fields. If empty, the select field is replaced with a disabled text input.
requiredbooleanfalseNoMarks the field as required.
sectionstringundefinedNoGroups fields under a section header.

Accessibility

  • Semantic input and select elements with aria-label and aria-required attributes.
  • ARIA live regions (aria-live="polite") for error and success messages to ensure screen reader compatibility.
  • Full keyboard navigation support for inputs, buttons, and select elements (via Enter and Space keys).
  • Visible asterisks for required fields and high-contrast styling for readability.
  • Error states with subtle shake animations and success states with green borders.

Styling

  • Uses Tailwind CSS for responsive grid layouts and retro aesthetics.
  • Dark mode support with gradient backgrounds (purple-blue-indigo).
  • 3D effects with transform-gpu, box-shadow, and perspective for a nostalgic look.
  • Smooth hover and focus animations using transition-all and cubic-bezier curves.
  • Theming support with a theme object for primary, success, and error colors.

Notes

  • The OTP functionality (showOTP) is a placeholder and logs to the console. For production, integrate with an OTP service like Twilio or Firebase.
  • For large forms, consider using react-hook-form for optimized state management and validation.
  • Styles are Tailwind-specific but can be extracted to a CSS module for non-Tailwind projects.