Overview
The Contact component provides a fully functional contact form that integrates with EmailJS to send messages directly to your email. It features form validation, error handling, and social media links, all styled with a neomorphic design.Features
- EmailJS integration for serverless email sending
- Real-time form validation
- Error state management with shake animation
- Social media links (LinkedIn, Instagram)
- Responsive layout with glowing accent effect
- Styled with CSS Modules
Implementation
The component is located atsrc/components/Contact/Contact.jsx:
EmailJS Configuration
Required Environment Variables
Create a.env file in your project root with the following variables:
Setup Steps
-
Create an EmailJS Account
- Sign up at EmailJS
- Create a new email service (Gmail, Outlook, etc.)
-
Get Your Service ID
- Navigate to Email Services
- Copy your Service ID
- Add to
.envasVITE_EMAILJS_SERVICE_ID
-
Create an Email Template
- Go to Email Templates
- Create a new template with these template variables:
{{name}}- Sender’s name{{email}}- Sender’s email{{message}}- Message content
- Copy the Template ID
- Add to
.envasVITE_EMAILJS_TEMPLATE_ID
-
Get Your Public Key
- Navigate to Account → General
- Copy your Public Key
- Add to
.envasVITE_EMAILJS_PUBLIC_KEY
- Install EmailJS Package
State Management
The component uses React hooks to manage form state:name- Stores the name input valueemail- Stores the email input valuemessage- Stores the message textarea valueerror- Stores validation error messages
Form Validation
The form validates that all fields are filled before submission:setTimeout trick triggers the shake animation by forcing a re-render.
CSS Module Styling
Key Styles
Container with Glow Effect:Customization
Update Section Title
Modify the title text inContact.jsx:
Update Subtitle
Change the subtitle message:Update Social Links
Replace the social media URLs:Customize Colors
Update CSS variables inindex.css:
Modify Form Fields
Add additional form fields by following the existing pattern:Accessibility
- All form inputs have associated labels with
htmlForattributes - Semantic HTML (
<section>,<form>,<label>) - Focus states for keyboard navigation
- ARIA-compliant form structure
Browser Support
- Modern browsers (Chrome, Firefox, Safari, Edge)
- CSS Grid and Flexbox support required
- CSS custom properties (variables) support required