Skip to main content
Version: 1.0.3

Multi-Step Form

A comprehensive multi-step form wizard that guides users through complex data collection processes. Features include step-by-step navigation, field validation, progress tracking, review screen, and multiple visual themes. Perfect for onboarding flows, registration processes, checkout forms, and any multi-stage data collection.

Installation

ignix add component multiStepForm

Example Usage

Onboarding Form

1
2
3
4

Personal Information

Tell us a bit about yourself

Step 1 of 3

interfaces

export type FieldValue = string | boolean | number | undefined;
export type FormValues = Record<string, FieldValue>;
export type ValidationErrors = Record<string, string>;

export interface FieldOption {
value: string;
label: string;
}

export interface FormField {
/** Unique identifier for the field */
id: string;

/** Field name used in form data object */
name: string;

/** Display label for the field */
label: string;

/** Input type */
type: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' |
'textarea' | 'select' | 'checkbox' | 'radio' | 'date';

/** Placeholder text for the input */
placeholder?: string;

/** Whether the field is required */
required?: boolean;

/** Options for select, radio, or checkbox fields */
options?: FieldOption[];

/** Custom validation function */
validation?: (value: FieldValue) => string | undefined;

/** Default value for the field */
defaultValue?: FieldValue;

/** Column span for grid layout ('full' or 'half') */
colSpan?: 'full' | 'half';

/** Icon component to display with the field */
icon?: React.ElementType;

/** Email-specific validation options */
emailValidation?: {
/** Use default email pattern */
pattern?: boolean;
/** Custom regex pattern for email validation */
customPattern?: RegExp;
/** Allowed email domains */
domain?: string[];
/** Custom error message */
message?: string;
};
}

export interface FormStep {
/** Unique identifier for the step */
id: string;

/** Title displayed at the top of the step */
title: string;

/** Description text below the title */
description?: string;

/** Array of fields in this step */
fields: FormField[];

/** Custom validation function for the entire step */
validation?: (values: FormValues) => ValidationErrors;
}

export type FormData = Record<string, FieldValue>;

export interface Notification {
/** Unique identifier for the notification */
id: string;

/** Type of notification affecting styling */
type: 'success' | 'error' | 'info' | 'warning';

/** Message to display */
message: string;

/** Duration in milliseconds before auto-dismiss */
duration?: number;
}

Props

MultiStepForm Props

PropTypeDefaultDescription
stepsFormStep[]RequiredArray of step configurations defining the form structure
initialDataFormData{}Initial data to pre-populate the form fields
onSubmit(data: FormData) => Promise<void> | void-Callback function called when form is successfully submitted
onStepChange(step: number, data: FormData) => void-Callback triggered when user navigates to a different step
onCancel() => void-Callback when cancel button is clicked
variant"default" | "gradient" | "card" | "glass" | "dark"'default'Visual theme variant for the form container
animationVariant`"fadeUp""scaleIn""slideUp"
inputVariantstring'clean'Visual variant for input fields (clean, borderGlow, glassmorphism, shimmer, borderBeam)
buttonVariantstring'default'Visual variant for navigation buttons
buttonAnimationVariantstring-Animation variant for buttons (scaleHeartBeat, press3DSoft, spinSlow, etc.)
backButtonLabelstring'← Back'Custom label for the back navigation button
nextButtonLabelstring'Next →'Custom label for the next navigation button
submitButtonLabelstring'Submit'Custom label for the submit button on review step
cancelButtonLabelstring'Cancel'Custom label for the cancel button
reviewStepTitlestring'Review'Title displayed for the review step
isLoadingbooleanfalseShows a loading spinner while initial data is being fetched
isSubmittingbooleanfalseControls the submitting state (useful for external submission control)
showReviewStepbooleantrueWhether to include a review step before submission
showCancelButtonbooleantrueWhether to show the cancel button in navigation
showSuccessNotificationbooleantrueWhether to show a success notification after submission
successNotificationDurationnumber3000Duration in milliseconds for the success notification
successNotificationMessagestring'Form submitted successfully!'Message displayed in success notification
darkModebooleanfalseEnables dark mode styling

MultiStepHeader Props

PropTypeDefaultDescription
titlestring | React.ReactNode'Multi-Step Form'Title displayed in the header
iconReact.ReactNode<Zap />Icon displayed next to the title
childrenReact.ReactNode-Custom header content (overrides title and icon)
classNamestring-Additional CSS classes for the header
titleClassNamestring-Additional CSS classes for the title
iconClassNamestring-Additional CSS classes for the icon container
containerClassNamestring-Additional CSS classes for the container
titleVariant`'h1' | 'h2''h3''h4'
titleWeight'light' | 'normal' | 'medium' | 'semibold' | 'bold''semiboldFont weight for the title
titleColordefault | primary | secondary | muted | error | success | warning | inheritdefaultText color for the title
iconSizenumber16 Size of the icon in pixels

MultiStepStepIndicator Props

PropTypeDefaultDescription
variant`'default''pills''tabs'`
completedColorstring'bg-green-900 dark:bg-green-600'Background color for completed steps
completedTextColorstring'text-green-900 dark:text-green-600'Text color for completed step labels
classNamestring-Additional CSS classes

MultiStepContent Props

PropTypeDefaultDescription
childrenReact.ReactNode-Content for each step (should be wrapped in Step components)
classNamestring-Additional CSS classes for the content container

MultiStepField Props

PropTypeDefaultDescription
fieldFormFieldRequiredField configuration object defining the input behavior
classNamestring-Additional CSS classes for the field container

MultiStepReview Props

PropTypeDefaultDescription
onEditStep(step: number) => void-Callback when edit button is clicked for a step
childrenReact.ReactNode-Custom review content (overrides default review display)
classNamestring-Additional CSS classes

MultiStepNavigation Props

PropTypeDefaultDescription
backButtonLabelstring'← Back'Custom label for the back navigation button
nextButtonLabelstring'Next →'Custom label for the next navigation button
submitButtonLabelstring'Submit'Custom label for the submit button on review step
cancelButtonLabelstring'Cancel'Custom label for the cancel button
showCancelButtonbooleantrueWhether to show the cancel button in navigation
onCancel() => void-Callback when cancel button is clicked
classNamestring-Additional CSS classes

MultiStepNotification Props

PropTypeDefaultDescription
type'success' | 'error' | 'info' | 'warning'RequiredType of notification to display
messagestringRequiredMessage to display in the notification
onClose() => voidRequiredCallback when notification is closed
durationnumber3000Duration in milliseconds before auto-closing
classNamestring-Additional CSS classes

Features

  • Multi-Step Navigation: Guide users through complex forms with intuitive step-by-step progression
  • Field Validation: Built-in validation with support for custom validation functions per field
  • Step Validation: Validate entire steps with custom validation logic
  • Progress Tracking: Visual step indicator showing completion status and progress
  • Review Screen: Comprehensive review step to verify all information before submission
  • Multiple Field Types: Support for text, email, password, number, tel, url, textarea, select, checkbox, radio, and date fields
  • Compound Components: Flexible composition with Header, StepIndicator, Content, Navigation, Review, and Field components
  • Responsive Design: Fully responsive layout that works seamlessly across all screen sizes
  • Accessibility: ARIA labels, keyboard navigation, and screen reader support
  • Animations: Smooth step transitions with 5 animation variants (fadeUp, scaleIn, slideUp, slideLeft, slideRight)
  • Theme Support: 5 visual variants including default, gradient, card, glass, and dark
  • Input Variants: Multiple input styling options (clean, borderGlow, glassmorphism, shimmer, borderBeam)
  • Button Variants: Various button styles with animation support
  • State Management: Built-in form state management with error handling and touched fields
  • Notifications: Success and error notifications with customizable duration and messages
  • Loading States: Built-in loading and submitting states with spinners
  • Initial Data: Support for pre-populating form data
  • Customizable Labels: All button and header labels can be customized
  • TypeScript Support: Fully typed with comprehensive interfaces