ContactForm Component

Collect contact information and messages from users

ContactForm Component

The ContactForm component provides a form for collecting contact information and messages from users.

Basic Usage

import { ContactForm } from '@mantlz/nextjs';

export default function ContactPage() {
  return (
    <div className="container mx-auto p-4">
      <ContactForm 
        formId="your-form-id"
        title="Get in Touch"
        description="Have questions? We'd love to hear from you."
        customSubmitText="Send"
      />
    </div>
  );
}

Customizing Field Labels

You can customize all field labels and placeholders:

<ContactForm
  formId="your-form-id"
  nameLabel="Full Name"
  namePlaceholder="John Doe"
  emailLabel="Email Address"
  emailPlaceholder="john@example.com"
  subjectLabel="Message Topic"
  subjectPlaceholder="Support Request"
  messageLabel="Your Message"
  messagePlaceholder="Tell us how we can help you..."
/>

Event Handlers

<ContactForm
  formId="your-form-id"
  onSubmitSuccess={(data) => {
    // Handle successful submission
    console.log('Form submitted:', data);
    // Trigger analytics or other actions
  }}
  onSubmitError={(error) => {
    // Handle submission error
    console.error('Submission failed:', error);
  }}
/>

Post-Submission Redirects

After form submission, you can specify a redirect URL (STANDARD and PRO plans only):

<ContactForm
  formId="your-form-id"
  redirectUrl="/thank-you" // Custom redirect URL (premium feature)
/>

Note: Free plan users will always be redirected to Mantlz's hosted thank-you page.

Available Core Props

PropTypeDescription
formIdstringRequired. The ID of the form in your Mantlz dashboard.
customSubmitTextstringText for the submit button. Default: 'Send Message'
titlestringForm title text. Default: 'Contact Us'
descriptionstringForm description text. Default: 'Fill out the form below...'
nameLabelstringLabel for name field. Default: 'Name'
namePlaceholderstringPlaceholder for name field.
emailLabelstringLabel for email field. Default: 'Email'
emailPlaceholderstringPlaceholder for email field.
subjectLabelstringLabel for subject field. Default: 'Subject'
subjectPlaceholderstringPlaceholder for subject field.
messageLabelstringLabel for message field. Default: 'Message'
messagePlaceholderstringPlaceholder for message field.
onSubmitSuccessfunctionCallback fired on successful submission.
onSubmitErrorfunctionCallback fired on submission error.
redirectUrlstringURL to redirect to after successful submission (premium).

For appearance customization options, see the Appearance section.