- No data uploaded
- Instant results
Tailwind CSS Contact Form for React — Glassmorphism
A production-ready glassmorphism contact form: a contact card with name, email, a topic selector, a message textarea and a submit button. Pick your brand color, toggle dark mode and corner radius — the live preview and the React code update instantly in your browser.
Live component editor
export default function ContactForm() {
return (
<div className="w-full max-w-lg p-8 bg-white/60 backdrop-blur-xl border border-white/60 shadow-2xl rounded-xl">
<h2 className="text-2xl font-bold text-slate-900">Get in touch</h2>
<p className="mt-1 mb-6 text-sm text-slate-500">We usually reply within one business day.</p>
<form className="flex flex-col gap-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<div>
<label htmlFor="cf-name" className="block mb-1.5 text-sm font-medium text-slate-700">Name</label>
<input id="cf-name" type="text" autoComplete="name" className="block w-full px-3 py-2 text-sm rounded-lg border bg-white/70 border-white/80 text-slate-900 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-[#4f46e5] focus:border-[#4f46e5]" required />
</div>
<div>
<label htmlFor="cf-email" className="block mb-1.5 text-sm font-medium text-slate-700">Email</label>
<input id="cf-email" type="email" autoComplete="email" className="block w-full px-3 py-2 text-sm rounded-lg border bg-white/70 border-white/80 text-slate-900 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-[#4f46e5] focus:border-[#4f46e5]" required />
</div>
</div>
<div>
<label htmlFor="cf-topic" className="block mb-1.5 text-sm font-medium text-slate-700">Topic</label>
<select id="cf-topic" className="block w-full px-3 py-2 text-sm rounded-lg border bg-white/70 border-white/80 text-slate-900 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-[#4f46e5] focus:border-[#4f46e5]">
<option>General question</option>
<option>Sales</option>
<option>Support</option>
</select>
</div>
<div>
<label htmlFor="cf-message" className="block mb-1.5 text-sm font-medium text-slate-700">Message</label>
<textarea id="cf-message" rows="4" className="block w-full px-3 py-2 text-sm rounded-lg border bg-white/70 border-white/80 text-slate-900 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-[#4f46e5] focus:border-[#4f46e5]" placeholder="How can we help?" required></textarea>
</div>
<button type="submit" className="inline-flex items-center justify-center px-4 py-2.5 text-sm font-semibold rounded-lg bg-[#4f46e5] hover:bg-[#433cc3] text-white shadow-sm transition-colors focus:outline-none focus:ring-2 focus:ring-[#4f46e5] focus:ring-offset-2 focus:ring-offset-white">Send message</button>
</form>
</div>
);
}
More Tailwind components for React
All components →- FAQ Accordion A frequently-asked-questions section with four expandable items, each toggled by a button that exposes its state via aria-expanded
- Footer A multi-column site footer with a brand description, three link groups, a newsletter sign-up field and a copyright row
- Signup Form A registration card with name, email and password fields, a password hint, a terms-of-service checkbox and a primary call to action
- Cookie Consent Banner A GDPR-style cookie banner with equally prominent “Accept all” and “Reject all”, granular analytics/marketing toggles (off by default), stored consent and Google Consent Mode v2 signals
- Navbar A responsive top navigation bar with a logo, primary links, a sign-in/CTA pair on desktop and a collapsible hamburger menu on mobile
- Login Modal A centered sign-in dialog with email and password fields, “remember me”, a forgot-password link and a social sign-in button
- Pricing Table A three-tier pricing section with a monthly/yearly billing toggle, a highlighted “most popular” plan and feature checklists
- Hero Section A landing-page hero with an announcement badge, a large headline, supporting copy, primary and secondary calls to action and a row of social-proof stats
Install Tailwind CSS for React
Create a React project with Vite, then add Tailwind CSS v3:
npm create vite@latest my-app -- --template react
cd my-app
npm install
npm install -D tailwindcss@3 postcss autoprefixer
npx tailwindcss init -pSet content: ['./index.html', './src/**/*.{js,jsx}'] in tailwind.config.js, and add to src/index.css:
@tailwind base;
@tailwind components;
@tailwind utilities;The brand color is applied with arbitrary values such as bg-[#4f46e5], so no theme configuration is needed.
Use the contact form in React
// App.jsx
import ContactForm from './ContactForm';
export default function App() {
return <ContactForm />;
}Accessibility & customization
All controls have explicit labels, the <select> has a meaningful default option, and required fields use the native required attribute for built-in validation messages.
Every color, radius and dark-mode choice is baked into plain utility classes, so the copied code has no runtime dependency on this site. The glass style relies on backdrop-filter, supported in all current browsers; place it over a colorful background for the best effect.
Compatibility
| Item | Details |
|---|---|
| CSS framework | Tailwind CSS v3.4+ |
| Library | React 18+ (function component) |
| Interactive state | None (static markup) |
| Dark mode | Yes — toggle in the editor |
| Style | Glassmorphism (backdrop blur) |