Documentation Index Fetch the complete documentation index at: https://mintlify.com/formsmd/formsmd/llms.txt
Use this file to discover all available pages before exploring further.
Build a straightforward contact form that collects essential information from visitors. This example demonstrates form validation, custom button text, and clean styling for professional contact forms.
Complete example
A single-page contact form with name, email, phone, and message fields.
import "formsmd/dist/css/formsmd.min.css" ;
import { Composer , Formsmd } from "formsmd" ;
const composer = new Composer ({
id: "contact-form" ,
postUrl: "/api/contact" ,
page: "single" ,
submitButtonText: "Send Message"
});
composer . textInput ( "name" , {
question: "Your name" ,
required: true ,
placeholder: "John Doe"
});
composer . emailInput ( "email" , {
question: "Email address" ,
required: true ,
placeholder: "john@example.com"
});
composer . telInput ( "phone" , {
question: "Phone number" ,
placeholder: "(555) 123-4567" ,
country: "US"
});
composer . selectBox ( "topic" , {
question: "What can we help you with?" ,
required: true ,
placeholder: "Select a topic" ,
options: [
"General Inquiry" ,
"Technical Support" ,
"Sales" ,
"Partnership" ,
"Other"
]
});
composer . textInput ( "message" , {
question: "Your message" ,
required: true ,
multiline: true ,
placeholder: "Tell us how we can help..."
});
const formsmd = new Formsmd (
composer . template ,
document . getElementById ( "contact-form-container" ),
{
themeLight: {
accent: "#2563eb" ,
accentForeground: "#ffffff"
},
themeDark: {
accent: "#3b82f6" ,
accentForeground: "#ffffff"
}
}
);
formsmd . init ();
Key features explained
Single page layout
Use page: "single" to display all fields on one page without slides. const composer = new Composer ({
page: "single" ,
submitButtonText: "Send Message"
});
Field validation
Forms.md automatically validates email addresses, phone numbers, and required fields. composer . emailInput ( "email" , {
question: "Email address" ,
required: true
});
Placeholders
Add helpful examples with the placeholder parameter. composer . textInput ( "name" , {
question: "Your name" ,
placeholder: "John Doe"
});
Custom theming
Apply brand colors for both light and dark modes. const formsmd = new Formsmd ( composer . template , container , {
themeLight: {
accent: "#2563eb" ,
accentForeground: "#ffffff"
}
});
Text input
Email input
Phone input
Select box
Basic text fields with optional multiline support. composer . textInput ( "message" , {
question: "Your message" ,
multiline: true ,
placeholder: "Tell us how we can help..."
});
Automatically validates email format. composer . emailInput ( "email" , {
question: "Email address" ,
required: true ,
placeholder: "john@example.com"
});
International phone input with country code selector. composer . telInput ( "phone" , {
question: "Phone number" ,
country: "US" ,
availableCountries: [ "US" , "CA" , "GB" ]
});
Dropdown menu for predefined options. composer . selectBox ( "topic" , {
question: "What can we help you with?" ,
placeholder: "Select a topic" ,
options: [ "Support" , "Sales" , "Other" ]
});
Validation examples
Required fields
Pattern matching
Character limits
composer . textInput ( "name" , {
question: "Your name" ,
required: true
});
All validation happens automatically on the client side. The form won’t submit until all required fields are filled correctly.
Customization tips
Brand the submit button : Change the default “Submit” text with submitButtonText in the Composer settings.
Match your brand colors : Use themeLight and themeDark options to apply your brand colors to buttons and form elements.
Add helper text : Use the description parameter to provide additional context or examples for complex fields.
Restrict phone countries : Use availableCountries to limit the phone input to specific regions if you only serve certain markets.
Advanced validation
You can add custom validation patterns using the pattern parameter:
composer . textInput ( "website" , {
question: "Company website" ,
pattern: "https?://.+" ,
placeholder: "https://example.com"
});
Next steps