Mantlz Component
TheMantlz component is the primary form component for rendering dynamic forms in your application. It fetches form configuration from the Mantlz API and renders a fully functional form with validation, submission handling, and customizable theming.
Import
Basic Usage
Props
Unique identifier for your form. This ID is provided when you create a form in the Mantlz dashboard.
Built-in theme to use for the form. Available themes:
default: Clean, minimal designmodern: Contemporary styling with subtle shadowsneobrutalism: Bold, high-contrast designsimple: Minimal styling for maximum customization
Custom styling configuration to override the default theme. See Appearance Configuration below.
Display the number of users who have joined (useful for waitlist forms). When enabled, the component will fetch and display the current count.
Initial count of users joined. This value will be updated by fetching the latest count from the API if
showUsersJoined is true.Custom label to display next to the users joined count.
URL to redirect to after successful form submission. For STANDARD/PRO plans, users will be redirected to this URL. Free plan users are always redirected to Mantlz’s hosted thank-you page.
Additional CSS class names to apply to the form container (currently commented out in implementation).
Appearance Configuration
Theappearance prop allows you to customize every aspect of your form’s styling.
Appearance Type
Appearance Variables
Primary color for buttons and interactive elements (e.g.,
'#6366f1')Background color for the form container
Background color for input fields
Default text color
Text color for input fields
Color for error messages
Color for success messages
Border radius for form elements (e.g.,
'8px', '12px')Font family for all text (e.g.,
'Inter, sans-serif')Base font size (e.g.,
'16px', '1rem')Base font weight (e.g.,
'400', 'normal')Appearance Elements
Customize specific form elements with CSS class names:CSS classes for the main form container
CSS classes for the form title
CSS classes for the form description
CSS classes for form field containers
CSS classes for form labels
CSS classes for form inputs
CSS classes for form buttons
CSS classes for error messages
CSS classes for the users joined display
Examples
Basic Form
Waitlist Form with User Count
Themed Form
Custom Styled Form
Form with Custom Redirect
Form Types
The Mantlz component supports various form types configured in your dashboard:- waitlist: Email collection with optional user count display
- contact: Contact forms with customizable fields
- feedback: Feedback collection with rating systems
- survey: Multi-step surveys with conditional logic
- application: Job applications and form submissions
- order: Product ordering forms (currently under development)
- analytics-opt-in: GDPR-compliant analytics consent
- rsvp: Event RSVP forms
- custom: Fully customizable forms
Behavior
Loading States
The component displays a loading spinner while:- Fetching the form configuration from the API
- Component is mounting
Error States
The component displays error messages for:- Missing
formIdprop - Missing API key (shows
ApiKeyErrorCard) - Failed form configuration fetch
- Empty form configuration
Submission Handling
- Form validates input using the configured validation rules
- Submits data to Mantlz API
- Handles success:
- Redirects to
redirectUrlif provided (STANDARD/PRO plans) - Redirects to Mantlz hosted page for free plans
- Redirects to
- Handles errors:
- Displays duplicate entry errors with toast notification
- Shows generic error messages for other failures
Users Joined Count
WhenshowUsersJoined is enabled:
- Fetches the current count on component mount
- Refreshes count every 60 seconds
- Only displays if count > 0
TypeScript Types
Notes
- The component must be wrapped in a
MantlzProviderwith a valid API key - The component is marked with
"use client"and requires a client-side environment - Form fields are dynamically generated based on the form configuration from the API
- The component uses Radix UI primitives for form handling
- Toast notifications are used for error messaging
- Order form functionality is currently under development