splitforms.com
TAILWIND CSS · CONTACT FORM

Beautifully styled contact form with Tailwind CSS

A polished, accessible, dark-mode-ready Tailwind contact form template. Drop into any project that has Tailwind configured — Next.js, React, Astro, Vue, Svelte, plain HTML. Includes focus rings, validation states, loading spinner, and a working backend.

1,000 free submissions every month.·No credit card.
contact.htmlhtml32 lines
01<form
02 action="https://splitforms.com/api/submit"
03 method="POST"
04 class="max-w-md mx-auto space-y-4 p-6 bg-white rounded-2xl border border-gray-200"
05>
06 <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
07
08 <div>
09 <label class="block text-sm font-semibold text-gray-700 mb-1">Name</label>
10 <input name="name" type="text" required
11 class="w-full rounded-lg border border-gray-300 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-orange-500" />
12 </div>
13
14 <div>
15 <label class="block text-sm font-semibold text-gray-700 mb-1">Email</label>
16 <input name="email" type="email" required
17 class="w-full rounded-lg border border-gray-300 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-orange-500" />
18 </div>
19
20 <div>
21 <label class="block text-sm font-semibold text-gray-700 mb-1">Message</label>
22 <textarea name="message" rows="4" required
23 class="w-full rounded-lg border border-gray-300 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-orange-500" />
24 </div>
25
26 <input type="checkbox" name="botcheck" class="hidden" tabindex="-1" />
27
28 <button type="submit"
29 class="w-full bg-orange-600 hover:bg-orange-700 text-white font-semibold py-2 rounded-lg transition">
30 Send message
31 </button>
32</form>
1,000
submissions / mo, free
14ms
median latency, edge
0
lines of backend code
17+
frameworks supported
✶ Live preview

What your Tailwind CSS contact form actually looks like.

Drop-in form backend with spam filtering, signed webhooks, and a real submissions dashboard. The same code in this preview is what you copy into your Tailwind CSS project — no SDK, no plugin, no PHP.

  • 1,000 submissions per month, free forever
  • Honeypot + AI spam classifier on every plan
  • Signed webhooks to Slack, Discord, your server
Tailwind CSS contact form on Splitforms — drop-in form backend with spam filtering and webhooks
§ 01Setup3 steps · 60 seconds · zero config

Ship a Tailwind CSS contact form without a backend.

No SDK, no PHP, no plugin. Your form posts standard FormData to one URL — submissions land in your inbox.

STEP 01GENERATE

Get your free access key

Verify your email and your access key is generated instantly. Free for 1,000 submissions per month, forever.

Create your form

By signing up, you agree to our terms and privacy policy.

STEP 02EMBED

Drop in the Tailwind CSS code

Copy the Tailwind CSS snippet on the right and paste it into your project. Replace YOUR_ACCESS_KEY with the key from step 1.

snippethtml
<form
…
STEP 03RECEIVE

Submissions land in your inbox

Hits your dashboard and email in seconds. Forward to Slack, Discord, Sheets, Notion, or any signed webhook URL.

inbox · 1 newjust now
FROM contact@yoursite.com
New Tailwind CSS form submission
Maya Iyer maya@studio71.co
Loved the new pricing page — quick question about the 4-year plan. Are usage limits per project or account-wide?
§ 02Live demosandboxed · no key required · no submission sent

Try it now — no signup, no key.

This is a styled HTML preview of what your Tailwind CSS form will look like. Submitting opens a confirmation, no real request is sent.

preview · tailwind csslocalhost:3000
✦ what just happened

Your Tailwind CSS form posts FormData to /api/submit. Splitforms validates the access key, runs the spam classifier, and forwards the parsed submission to your inbox plus the dashboard.

  • 14ms median round-trip from the edge.
  • Honeypot + classifier, no CAPTCHA.
  • Per-domain key locking out of the box.
REQUEST · POST /api/submit
{
  "access_key": "sk_live_4f9a_••••",
  "name":       "Maya Iyer",
  "email":      "maya@studio71.co",
  "message":    "…"
}
← 200 OK · { "success": true } · 14ms
§ 03Best practices5 rules · production-tested

How to ship this without regrets.

Five rules that make the difference between a form that works in the demo and a form that survives launch traffic.

  1. 01

    Wrap each input in a `<div>` with the label — gives you a stable spacing block. Easier to reorder fields without re-adding `mb-4` everywhere.

  2. 02

    Use `focus:ring-2 focus:ring-offset-2` for accessibility — sighted keyboard users need to see where focus is, and screen readers don't care.

  3. 03

    Add `aria-busy={status === 'loading'}` to the form element. Tailwind doesn't style aria-busy by default, but screen readers announce the change.

  4. 04

    For dark mode, define your accent color as a CSS variable in @layer base — then `bg-[var(--accent)]` works regardless of light/dark.

  5. 05

    Don't use `disabled:opacity-50` alone for the submit button — pair with `disabled:cursor-not-allowed` and `disabled:bg-gray-400` so the state is unmistakable.

§ 04Common gotchas in Tailwind CSS6 edge cases worth knowing

What bites people who skip the docs.

Worth a 60-second skim before you ship to production. Each one has caused a Tailwind CSS support ticket at least once.

⚠ gotcha

JIT mode purges classes inside template strings

If you build the form HTML inside a JS template literal, Tailwind's JIT can't see your classes and purges them. Either move the markup into a .html / .tsx / .vue file, or add the classes to your safelist in tailwind.config.js.

⚠ gotcha

Tailwind 4's @theme replaces tailwind.config.js — focus colors break

Tailwind 4 (released 2026) moved theme tokens into CSS via @theme { … }. If you copy a Tailwind 3 snippet using focus:ring-orange-500, the orange-500 token has to be defined in your @theme block or it falls back to no ring color. Use a CSS variable: focus:ring-[var(--accent)] for portability.

⚠ gotcha

Form gets no styling at all — Preflight not loaded

If you're embedding the form inside a Shadow DOM, iframe, or a CMS that strips global CSS, Tailwind's Preflight (the global reset) doesn't apply. Inputs render with browser-default white backgrounds, ignoring bg-white if you set it in @apply but not as a utility on the element. Always use utilities directly on the input.

⚠ gotcha

Dark mode classes need `class` strategy explicitly set

Tailwind defaults to media-query dark mode (prefers-color-scheme). If your form has dark:bg-gray-900 and you toggle dark mode via a class on <html>, you need darkMode: 'class' in tailwind.config.js (Tailwind 3) or @variant dark (.dark &) in your CSS (Tailwind 4).

⚠ gotcha

@tailwindcss/forms plugin overrides splitforms styling

The official forms plugin resets input styles aggressively. Combined with our pre-styled snippet, you may get double-padded inputs. Either remove @tailwindcss/forms from your config, or use class="form-input" and let the plugin style everything.

⚠ gotcha

peer-invalid + required fires on first paint, painting your form red on load

Adding peer-invalid:border-red-500 to inputs styled by a sibling peer class seems clean — but the :invalid pseudo-class is true the moment a required empty input renders, so the whole form lights up red before the user has typed anything. Combine with :user-invalid (modern browsers) or guard with peer-[:not(:placeholder-shown)]:peer-invalid:border-red-500 so red only appears after the user has actually interacted. Tailwind 3.4+ adds the user-invalid variant directly; earlier versions need an arbitrary variant.

§ 04bNative Tailwind CSS forms…and where they break down

How Tailwind CSS handles forms without splitforms.

The shape of the problem before splitforms enters the picture — and the gap it fills for Tailwind CSS specifically.

Tailwind is a styling layer — it has no opinion on form submission, networking, or backend. The 'native' approach means writing utility classes for visual treatment and bringing your own delivery mechanism: a Next.js route handler, a Vite + React + fetch combo, an HTMX endpoint, etc. Tailwind UI ($299 one-time) sells styled form templates but doesn't include a backend either. Tailwind v4's @theme directive changes how tokens are defined, not what forms do. The shape of the problem stays: utility classes for look-and-feel, splitforms for delivery. Drop the snippet on this page into any framework with Tailwind configured and you have a styled, working form in 60 seconds.

§ 04cAlternative integration patterns2 ways to wire it

Two ways to ship splitforms on Tailwind CSS.

Pick the pattern that matches your constraints — JS budget, key-exposure tolerance, server-side opacity. Both produce the same result.

PATTERN A

Pattern A — utility-first inline styles

Every input gets utilities directly on the element — explicit, JIT-safe, no @apply indirection. Works in HTML, JSX, TSX, Vue, Svelte, Astro identically.

pattern-a.htmlhtml12 lines
01<form action="https://splitforms.com/api/submit" method="POST"
02 class="max-w-md mx-auto space-y-4 p-6 bg-white rounded-2xl border border-gray-200">
03 <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
04 <input name="email" type="email" required
05 class="w-full rounded-lg border px-3 py-2 focus:ring-2 focus:ring-orange-500" />
06 <textarea name="message" rows="4" required
07 class="w-full rounded-lg border px-3 py-2 focus:ring-2 focus:ring-orange-500" />
08 <button type="submit"
09 class="w-full bg-orange-600 hover:bg-orange-700 text-white font-semibold py-2 rounded-lg">
10 Send
11 </button>
12</form>
PATTERN B

Pattern B — dark-mode + accessible focus states (Tailwind v4)

Pairs dark: variants with focus-visible: for keyboard-only focus rings. Uses CSS variables for accent color so the same component works in light/dark without rewriting utilities.

pattern-b.htmlhtml9 lines
01<form action="https://splitforms.com/api/submit" method="POST"
02 class="max-w-md mx-auto p-6 rounded-2xl border bg-white dark:bg-zinc-900 dark:border-zinc-800">
03 <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
04 <input name="email" type="email" required
05 class="w-full rounded-lg border bg-white dark:bg-zinc-950 px-3 py-2
06 text-gray-900 dark:text-zinc-100
07 focus-visible:ring-2 focus-visible:ring-[var(--accent)]" />
08 <button class="w-full bg-[var(--accent)] text-white py-2 rounded-lg">Send</button>
09</form>
§ 04dDeployment notes for Tailwind CSShosting · env vars · CSP

Shipping Tailwind CSS + splitforms to production.

Host-specific gotchas, env-var conventions, and the boring-but-load-bearing details for putting this on the public internet.

Tailwind is purely a build-time concern — utilities are compiled into your CSS bundle, then deployed as static assets. JIT mode (default in v3+) and the v4 engine both purge unused classes; if you build form HTML inside a JS template literal at runtime, Tailwind can't see those classes and purges them — add to safelist or move markup into source files. Works on every host. For dark mode toggled via class, set darkMode: 'class' in v3 config or use @variant dark (.dark &) in v4 CSS. The @tailwindcss/forms plugin resets input styles aggressively — pick one (plugin OR explicit utilities), not both.

§ 05Comparisonvs native tailwind css

splitforms vs native tailwind css.

What you get for free vs what you build, pay for, or do without.

FeatureNative Tailwind CSSsplitforms
Setup timeStyle every input from scratchCopy one snippet
AccessibilityManually add aria attributesBuilt-in
Dark modeAdd `dark:` variants to every utilityIncluded in alternative snippet
BackendTailwind doesn't ship oneSplitforms (free 1,000/mo)
Spam filteringN/AHoneypot + classifier
Tailwind UI cost$299 one-time (form section)$0
§ 06Alternative patternhtml · 44 lines
ALTERNATIVE

Dark-mode-ready variant with loading spinner

Same form, plus dark-mode classes, an inline SVG spinner during submit, and accessible aria-live for status changes. Tailwind 3 and 4 compatible.

alternative.htmlhtml44 lines
01<form
02 action="https://splitforms.com/api/submit"
03 method="POST"
04 class="max-w-md mx-auto space-y-4 p-6 rounded-2xl border bg-white dark:bg-zinc-900 border-gray-200 dark:border-zinc-800"
05>
06 <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
07
08 <div>
09 <label for="name" class="block text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1">Name</label>
10 <input id="name" name="name" type="text" required
11 class="w-full rounded-lg border border-gray-300 dark:border-zinc-700 bg-white dark:bg-zinc-950
12 px-3 py-2 text-gray-900 dark:text-zinc-100
13 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent
14 transition-colors" />
15 </div>
16
17 <div>
18 <label for="email" class="block text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1">Email</label>
19 <input id="email" name="email" type="email" required
20 class="w-full rounded-lg border border-gray-300 dark:border-zinc-700 bg-white dark:bg-zinc-950
21 px-3 py-2 text-gray-900 dark:text-zinc-100
22 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent
23 transition-colors" />
24 </div>
25
26 <div>
27 <label for="message" class="block text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1">Message</label>
28 <textarea id="message" name="message" rows="4" required
29 class="w-full rounded-lg border border-gray-300 dark:border-zinc-700 bg-white dark:bg-zinc-950
30 px-3 py-2 text-gray-900 dark:text-zinc-100
31 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent
32 transition-colors resize-y"></textarea>
33 </div>
34
35 <input type="checkbox" name="botcheck" class="hidden" tabindex="-1" />
36
37 <button type="submit"
38 class="w-full inline-flex justify-center items-center gap-2
39 bg-orange-600 hover:bg-orange-700 disabled:bg-gray-400 disabled:cursor-not-allowed
40 text-white font-semibold py-2 rounded-lg transition-colors
41 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2 dark:focus:ring-offset-zinc-900">
42 Send message
43 </button>
44</form>
§ 07Questions6 answered

Things developers ask before they integrate.

Direct answers, no marketing fluff. Missing one? Email hello@splitforms.com.

01How do I add a Tailwind contact form to my project?
Copy the snippet above into any component or HTML file. Make sure Tailwind is already configured in your project (you'd see tailwind.config.js and the @tailwind directives in your CSS). Replace YOUR_ACCESS_KEY with your splitforms key.
02Does this work with Tailwind 3 and Tailwind 4?
Yes. The hero snippet uses utilities that exist in both versions. The dark-mode alternative uses dark: variants — ensure your config has the dark-mode strategy you want (media or class).
03How do I handle form errors with Tailwind classes?
Add a hidden error <p> below the form and toggle visibility on submit. Tailwind utilities for error state: text-red-600 dark:text-red-400 text-sm mt-2. The fetch returns { success, message } — toggle the p's hidden class based on success.
04Can I use this with the @tailwindcss/forms plugin?
Yes, but the plugin resets input styles. Either remove the snippet's per-input padding/border classes (the plugin will style them), or remove the plugin from your config and use the snippet's explicit utilities.
05How do I customize the success / redirect behavior?
Add a hidden redirect input pointing to your thank-you page URL — splitforms 302s after a successful submit. For inline confirmation (no redirect), wrap the form in a JS handler and toggle a Tailwind-styled success <div> with hidden class.
06Does the snippet work in dark mode automatically?
The hero snippet is light-mode only (so it works regardless of your dark-mode setup). The alternative-pattern snippet includes full dark: variants — use it if your project supports dark mode.
✻ ✻ ✻

Ship your Tailwind CSS contact form in 60 seconds.

1,000 free submissions per month. No credit card. Lock the access key to your domains, paste the snippet, watch submissions land in your inbox.

Get free access key →Read the docs
v0.1 · founders pricing locked in · early access open