How to Add a Feedback Button in HTML
A complete guide to implementing a feedback button on your website, from plain HTML to modern frameworks.
Method 1: Using Retour (Easiest - 60 seconds)
The fastest way to add a feedback button is using Retour. It handles everything: UI, storage, AI analysis, and Slack notifications.
Step 1: Install
npm i smart-feedbackStep 2: Initialize
import { setupFeedback } from 'smart-feedback';
(async function(){
const fw = await setupFeedback({
projectId: 'your-project-id',
apiBase: 'https://www.retour.tech',
attrs: { label: 'Feedback', color: '#4F46E5' }
});
document.getElementById('feedbackBtn')
?.addEventListener('click', () => fw.open());
})();Step 3: Add Button
<button id="feedbackBtn">Feedback</button>✅ Done! Your feedback button is live.
Method 2: Plain HTML + JavaScript (DIY)
If you want to build from scratch, here's a basic implementation:
HTML
<button id="feedbackBtn" onclick="openFeedbackModal()">
Feedback
</button>
<div id="feedbackModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeFeedbackModal()">×</span>
<h2>Send Feedback</h2>
<form id="feedbackForm">
<textarea id="feedbackText" placeholder="Your feedback..."></textarea>
<button type="submit">Submit</button>
</form>
</div>
</div>CSS
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #1e293b;
margin: 15% auto;
padding: 20px;
border-radius: 8px;
width: 400px;
max-width: 90%;
}JavaScript
function openFeedbackModal() {
document.getElementById('feedbackModal').style.display = 'block';
}
function closeFeedbackModal() {
document.getElementById('feedbackModal').style.display = 'none';
}
document.getElementById('feedbackForm').addEventListener('submit', async (e) => {
e.preventDefault();
const feedback = document.getElementById('feedbackText').value;
await fetch('/api/feedback', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ feedback })
});
closeFeedbackModal();
alert('Thanks for your feedback!');
});Method 3: React/Next.js Component
'use client';
import { useState } from 'react';
export function FeedbackButton() {
const [isOpen, setIsOpen] = useState(false);
const [feedback, setFeedback] = useState('');
const handleSubmit = async (e) => {
e.preventDefault();
await fetch('/api/feedback', {
method: 'POST',
body: JSON.stringify({ feedback })
});
setIsOpen(false);
setFeedback('');
};
return (
<>
<button onClick={() => setIsOpen(true)}>
Feedback
</button>
{isOpen && (
<div className="modal">
<form onSubmit={handleSubmit}>
<textarea
value={feedback}
onChange={(e) => setFeedback(e.target.value)}
placeholder="Your feedback..."
/>
<button type="submit">Submit</button>
</form>
</div>
)}
</>
);
}Comparison: Build vs Buy
| Feature | DIY | Retour |
|---|---|---|
| Setup Time | 4-8 hours | 60 seconds |
| Database/Storage | You manage | Included |
| AI Analysis | Extra work | Built-in |
| Slack Integration | Custom build | 1-click |
| Maintenance | On you | Zero |
Conclusion
Building a custom feedback button is educational, but for production use, a ready-made solution like Retour saves weeks of development and ongoing maintenance.