Creating a Pomodoro Timer Website with a beautiful UI and features involves combining HTML, CSS, and JavaScript to build an interactive, visually appealing timer. Below is a complete implementation of a Pomodoro Timer web app with:
- A clean and modern UI
- 25-minute work session (default)
- 5-minute short break
- 15-minute long break after every 4 cycles
- Start, Pause, Reset buttons
- Session counter
- Sound alert on session completion
- Responsive design
✅ Features:
- Work & Break Sessions
- Visual Progress Bar
- Sounds for session end
- Mobile-friendly responsive layout
- Customizable session durations
- Completed sessions count
📁 Project Structure
pomodoro-timer/
├── index.html
├── style.css
└── script.js
🧩 index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Pomodoro Timer</title>
<link rel="stylesheet" href="style.css" />
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>🍅 Pomodoro Timer</h1>
<div class="timer-display">
<span id="minutes">25</span>:<span id="seconds">00</span>
</div>
<div class="controls">
<button id="start">Start</button>
<button id="pause">Pause</button>
<button id="reset">Reset</button>
</div>
<div class="session-controls">
<label>
Work Duration:
<input type="number" id="workDuration" value="25" min="1" max="60"/>
</label>
<label>
Short Break:
<input type="number" id="shortBreak" value="5" min="1" max="30"/>
</label>
<label>
Long Break:
<input type="number" id="longBreak" value="15" min="1" max="60"/>
</label>
</div>
<div class="progress-container">
<div class="progress-bar" id="progressBar"></div>
</div>
<div class="session-count">
Sessions Completed: <span id="sessionsCompleted">0</span>
</div>
</div>
<audio id="alarmSound" src="https://www.soundjay.com/buttons/sounds/beep-07.mp3"></audio>
<script src="script.js"></script>
</body>
</html>
🎨 style.css
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Roboto', sans-serif;
background: #f4f4f4;
color: #333;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
text-align: center;
background: white;
padding: 30px;
border-radius: 15px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
width: 90%;
max-width: 400px;
}
h1 {
margin-bottom: 20px;
color: #e63946;
}
.timer-display {
font-size: 4rem;
margin: 20px 0;
}
.controls button {
background-color: #e63946;
color: white;
border: none;
padding: 10px 15px;
margin: 5px;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
}
.controls button:hover {
background-color: #d02a3b;
}
.session-controls {
margin-top: 20px;
display: flex;
flex-direction: column;
gap: 10px;
}
.session-controls label {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.9rem;
}
.session-controls input {
width: 40px;
padding: 5px;
font-size: 0.9rem;
text-align: center;
}
.progress-container {
margin: 20px auto;
width: 100%;
height: 10px;
background: #ddd;
border-radius: 10px;
overflow: hidden;
}
.progressBar {
height: 100%;
width: 0%;
background: #4caf50;
transition: width 0.5s;
}
.session-count {
margin-top: 15px;
font-size: 1rem;
}
⚙️ script.js
const minutesDisplay = document.getElementById("minutes");
const secondsDisplay = document.getElementById("seconds");
const startBtn = document.getElementById("start");
const pauseBtn = document.getElementById("pause");
const resetBtn = document.getElementById("reset");
const progressBar = document.getElementById("progressBar");
const workDurationInput = document.getElementById("workDuration");
const shortBreakInput = document.getElementById("shortBreak");
const longBreakInput = document.getElementById("longBreak");
const alarmSound = document.getElementById("alarmSound");
let totalSeconds = 25 * 60;
let timerInterval = null;
let isRunning = false;
let sessionType = "work"; // work | shortBreak | longBreak
let completedSessions = 0;
function updateDisplay() {
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
minutesDisplay.textContent = String(minutes).padStart(2, "0");
secondsDisplay.textContent = String(seconds).padStart(2, "0");
}
function startTimer() {
if (!isRunning) {
isRunning = true;
timerInterval = setInterval(() => {
if (totalSeconds > 0) {
totalSeconds--;
updateDisplay();
updateProgress();
} else {
clearInterval(timerInterval);
isRunning = false;
alarmSound.play();
handleSessionEnd();
}
}, 1000);
}
}
function pauseTimer() {
clearInterval(timerInterval);
isRunning = false;
}
function resetTimer() {
clearInterval(timerInterval);
isRunning = false;
sessionType = "work";
setInitialTime();
updateDisplay();
updateProgress();
}
function setInitialTime() {
let duration = 25 * 60;
if (sessionType === "work") {
duration = parseInt(workDurationInput.value) * 60;
} else if (sessionType === "shortBreak") {
duration = parseInt(shortBreakInput.value) * 60;
} else if (sessionType === "longBreak") {
duration = parseInt(longBreakInput.value) * 60;
}
totalSeconds = duration;
}
function updateProgress() {
const duration = parseInt(workDurationInput.value) * 60;
const percentage = ((duration - totalSeconds) / duration) * 100;
progressBar.style.width = `${percentage}%`;
}
function handleSessionEnd() {
if (sessionType === "work") {
completedSessions++;
document.getElementById("sessionsCompleted").textContent = completedSessions;
sessionType = completedSessions % 4 === 0 ? "longBreak" : "shortBreak";
} else {
sessionType = "work";
}
setInitialTime();
updateDisplay();
}
startBtn.addEventListener("click", startTimer);
pauseBtn.addEventListener("click", pauseTimer);
resetBtn.addEventListener("click", resetTimer);
// Update time when inputs change
[workDurationInput, shortBreakInput, longBreakInput].forEach(input => {
input.addEventListener("change", () => {
if (!isRunning) {
setInitialTime();
updateDisplay();
}
});
});
🔊 Optional Enhancements
- Add custom sound files instead of the beep.
- Add dark mode toggle.
- Store session count in local storage.
- Animate progress bar smoothly.
- Add mobile touch support.
📱 Preview
You can preview this by opening the HTML file in a browser or deploying it using tools like:
Would you like me to package this as a downloadable ZIP or deployable GitHub repo?