Jul 4, 2025 • 3 min read
Best Way to Build Forms with Tailwind and a Form API

Aditya
Founder

If you’re a developer, you’ve probably run into this situation:
You need a simple form — maybe a contact form, feedback box, or a lead capture form — but you
don’t want to mess with setting up a whole backend just to handle submissions.
There are a bunch of form builders like Typeform, Google Forms, Tally, and so on. But they restrict how much control you have over the user interface and how it integrates with the rest of your site.
It ends up looking very disconnected from the rest of your site.
That’s where Tailwind + a Form API backend comes in. And if you’re using DevMatter, it becomes even simpler.
Let’s walk through the best way to build custom forms with Tailwind CSS and handle submissions through DevMatter — so you can go from idea to working form in minutes.
Why Use Tailwind for Custom Forms?
Tailwind makes it incredibly easy to build beautiful, clean forms. You can customize everything — spacing, fonts, colors — without ever writing a line of CSS.
Here’s a quick example of a styled form using Tailwind:
<form id="contactForm" class="mx-auto mt-10 max-w-md space-y-4 rounded-xl bg-zinc-50 p-6 text-sm shadow">
<input type="text" name="name" placeholder="Your Name" class="w-full rounded-lg border border-zinc-300 bg-white px-4 py-2" required />
<input type="email" name="email" placeholder="Your Email" class="w-full rounded-lg border border-zinc-300 bg-white px-4 py-2" required />
<textarea name="message" placeholder="Your Message" class="w-full rounded-lg border border-zinc-300 bg-white px-4 py-2" rows="4" required></textarea>
<button type="submit" class="rounded-lg bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700">Send</button>
</form>

Looks professional, works everywhere, and loads fast. No CSS frameworks or design systems to fight with.
With a couple of easy to learn utility classes, you can get your form pages looking amazing and exactly how you like it.
Why Use a Form API Backend?
Instead of building your own backend or using a bloated form builder, a form API backend gives you:
- 🔄 Instant integration with your front-end
- 🔔 Real-time notifications when you get submissions
- 📱 A mobile app (with DevMatter) to view submissions on the go
- ✅ Full control over how the form looks, works, and behaves
You write the form. DevMatter handles the backend.
Hooking Up DevMatter to Your Form
Once you’ve styled your form, you just need to hook it up to DevMatter. Here’s how:
1. Get your DevMatter Form API URL
Create a new form in your DevMatter dashboard. Copy the form URL (e.g. https://api.devmatter.app/form/123).
2. Add JavaScript to Send the Form
Here’s a basic example using fetch:
<script>
const form = document.getElementById('contactForm');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(form);
const json = Object.fromEntries(formData.entries());
const res = await fetch('https://api.devmatter.app/form/abc123', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(json),
});
if (res.ok) {
alert('Thanks! We got your message.');
form.reset();
} else {
alert('Oops! Something went wrong.');
}
});
</script>
That’s it. No backend needed. You’ll see new submissions instantly in the DevMatter mobile app — with push notifications if you want.
If you wanted, you could make it even simpler! Instead of using JavaScript as shown above, you can add the form URL in the action attribute of the form. This will automatically submit the form when a user clicks submit.
You can even configure your form to redirect to a success page upon successful submission!
Why Devs Love This Setup
- Total control: You write your form using Tailwind. No iframe embeds, no weird UI.
- Super fast: Just drop in an endpoint and you’re done.
- Real-time: Get notified the moment someone submits.
- Mobile-first: View all your submissions and leads on the go using the DevMatter app.
Explore More: Building Robust Forms
If you’re building something more complex — think multi-step forms, conditional logic, field validation, or complex schemas — there are great tools in the ecosystem you might want to check out:
- TanStack Form (react-form): Headless form logic for React, built by the creators of TanStack Table & Query.
- React Hook Form: Minimal yet powerful form library with great performance and DX.
- Zod: A TypeScript-first schema validation library that pairs well with any form setup.
- Formik: A classic form library for React apps, good for enterprise use cases.
These tools work great with Tailwind too — giving you even more power while keeping your styling consistent.
Final Thoughts
If you’re building a custom UI with Tailwind, don’t waste time building a backend from scratch just to collect form data. With DevMatter, you get an instant tailwind form API backend, real-time submission handling, and a clean mobile-first dashboard — all while keeping full control of your form’s experience.
Start using DevMatter for your next form — and ship faster with less friction.