The user wants a web-based stopwatch with start, stop, pause, and reset functionality. Let me create a visually striking, modern stopwatch that doesn't look like a generic template.
Let me think about the design:
- Aesthetic: I'll go for a technical/industrial vibe with a dark theme - something that feels like a professional timing instrument
- Font: I'll use a distinctive display font - maybe "JetBrains Mono" for the time display (technical feel) and "Space Grotesk" for UI elements
- Color scheme: Dark background with a sharp accent color - maybe a neon green or electric cyan for that instrument/technical feel
- Layout: Large, prominent time display with well-designed buttons below
- Interactions:
- Smooth transitions on button states
- Pulsing indicator when running
- Lap time recording feature (bonus)
- Staggered entrance animation
- Background: Subtle grid pattern or technical texture
Let me design this:
CSS Variables:
- --bg: dark charcoal
- --fg: light/white
- --muted: gray
- --accent: electric green/cyan
- --card: slightly lighter dark
- --border: subtle border color
Features:
- Start/Stop toggle button
- Reset button
- Lap functionality (record lap times)
- Display format: MM:SS.ms
- Smooth animations
- Responsive design
Let me write the code:
Here's a striking, technical-aesthetic stopwatch with lap functionality and polished interactions:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Precision Stopwatch</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Space+Grotesk:wght@400;600;700&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<style>
:root {
--bg: #0a0a0f;
--bg-secondary: #12121a;
--fg: #e8e8ed;
--muted: #5a5a6e;
--accent: #00ff88;
--accent-dim: rgba(0, 255, 136, 0.15);
--card: #16161f;
--border: #2a2a3a;
--danger: #ff4757;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
overflow-x: hidden;
}
/* Background grid pattern */
.bg-grid {
position: fixed;
inset: 0;
background-image:
linear-gradient(rgba(0, 255, 136, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 255, 136, 0.03) 1px, transparent 1px);
background-size: 50px 50px;
pointer-events: none;
z-index: 0;
}
/* Gradient orbs */
.orb {
position: fixed;
border-radius: 50%;
filter: blur(80px);
pointer-events: none;
z-index: 0;
}
.orb-1 {
width: 400px;
height: 400px;
background: radial-gradient(circle, rgba(0, 255, 136, 0.2), transparent 70%);
top: -100px;
right: -100px;
}
.orb-2 {
width: 300px;
height: 300px;
background: radial-gradient(circle, rgba(0, 200, 255, 0.1), transparent 70%);
bottom: -50px;
left: -50px;
}
/* Main container */
.container {
position: relative;
z-index: 1;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 2rem;
}
/* Stopwatch card */
.stopwatch-card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 24px;
padding: 3rem 2.5rem;
max-width: 480px;
width: 100%;
box-shadow:
0 4px 24px rgba(0, 0, 0, 0.4),
0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}
/* Header */
.header {
display: flex;
align-items: center;
justify-content: center;
gap: 0.75rem;
margin-bottom: 2.5rem;
opacity: 0;
transform: translateY(-20px);
animation: fadeInDown 0.6s ease forwards;
}
.status-indicator {
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--muted);
transition: all 0.3s ease;
}
.status-indicator.running {
background: var(--accent);
box-shadow: 0 0 12px var(--accent);
animation: pulse 1.5s ease-in-out infinite;
}
.status-indicator.paused {
background: #ffc107;
box-shadow: 0 0 12px rgba(255, 193, 7, 0.5);
}
.title {
font-size: 0.875rem;
font-weight: 600;
letter-spacing: 0.2em;
text-transform: uppercase;
color: var(--muted);
}
/* Time display */
.time-display {
font-family: 'JetBrains Mono', monospace;
text-align: center;
margin-bottom: 2.5rem;
opacity: 0;
transform: scale(0.9);
animation: fadeInScale 0.6s ease 0.15s forwards;
}
.time-main {
font-size: 4rem;
font-weight: 700;
letter-spacing: -0.02em;
line-height: 1;
margin-bottom: 0.5rem;
color: var(--fg);
transition: color 0.3s ease;
}
.time-main.running {
color: var(--accent);
}
.time-ms {
font-size: 1.5rem;
font-weight: 400;
color: var(--muted);
}
/* Buttons */
.controls {
display: flex;
gap: 1rem;
justify-content: center;
flex-wrap: wrap;
margin-bottom: 2rem;
opacity: 0;
transform: translateY(20px);
animation: fadeInUp 0.6s ease 0.3s forwards;
}
.btn {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 1rem 1.75rem;
border: none;
border-radius: 12px;
font-family: 'Space Grotesk', sans-serif;
font-size: 0.9375rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
position: relative;
overflow: hidden;
}
.btn:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.btn:active {
transform: scale(0.96);
}
.btn-primary {
background: var(--accent);
color: var(--bg);
min-width: 140px;
}
.btn-primary:hover {
background: #33ff9f;
box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
}
.btn-primary.paused {
background: #ffc107;
color: var(--bg);
}
.btn-primary.paused:hover {
background: #ffcd38;
box-shadow: 0 4px 20px rgba(255, 193, 7, 0.3);
}
.btn-secondary {
background: var(--bg-secondary);
color: var(--fg);
border: 1px solid var(--border);
}
.btn-secondary:hover {
background: var(--border);
border-color: var(--muted);
}
.btn-danger {
background: rgba(255, 71, 87, 0.1);
color: var(--danger);
border: 1px solid rgba(255, 71, 87, 0.3);
}
.btn-danger:hover {
background: rgba(255, 71, 87, 0.2);
border-color: var(--danger);
}
.btn-icon {
width: 52px;
height: 52px;
padding: 0;
min-width: auto;
}
/* Laps section */
.laps-section {
opacity: 0;
transform: translateY(20px);
animation: fadeInUp 0.6s ease 0.45s forwards;
}
.laps-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
padding-bottom: 0.75rem;
border-bottom: 1px solid var(--border);
}
.laps-title {
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.15em;
text-transform: uppercase;
color: var(--muted);
}
.laps-count {
font-family: 'JetBrains Mono', monospace;
font-size: 0.75rem;
color: var(--accent);
}
.laps-list {
max-height: 200px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.laps-list::-webkit-scrollbar {
width: 4px;
}
.laps-list::-webkit-scrollbar-track {
background: var(--bg-secondary);
border-radius: 2px;
}
.laps-list::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 2px;
}
.lap-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.75rem 1rem;
background: var(--bg-secondary);
border-radius: 8px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.875rem;
animation: lapSlideIn 0.3s ease;
}
.lap-number {
color: var(--muted);
}
.lap-time {
color: var(--fg);
}
.lap-diff {
font-size: 0.75rem;
color: var(--accent);
}
.empty-laps {
text-align: center;
padding: 2rem;
color: var(--muted);
font-size: 0.875rem;
}
/* Animations */
@keyframes fadeInDown {
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInUp {
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInScale {
to {
opacity: 1;
transform: scale(1);
}
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes lapSlideIn {
from {
opacity: 0;
transform: translateX(-20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* Responsive */
@media (max-width: 480px) {
.stopwatch-card {
padding: 2rem 1.5rem;
border-radius: 20px;
}
.time-main {
font-size: 3rem;
}
.time-ms {
font-size: 1.25rem;
}
.controls {
gap: 0.75rem;
}
.btn {
padding: 0.875rem 1.25rem;
font-size: 0.875rem;
}
}
</style>
</head>
<body>
<div class="bg-grid"></div>
<div class="orb orb-1"></div>
<div class="orb orb-2"></div>
<main class="container">
<div class="stopwatch-card">
<header class="header">
<div class="status-indicator" id="statusIndicator" aria-hidden="true"></div>
<span class="title" id="statusText">Ready</span>
</header>
<div class="time-display" role="timer" aria-live="polite" aria-atomic="true">
<div class="time-main" id="timeMain">00:00</div>
<div class="time-ms" id="timeMs">.00</div>
</div>
<div class="controls">
<button class="btn btn-primary" id="startStopBtn" aria-label="Start stopwatch">
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" id="playIcon">
<polygon points="5,3 19,12 5,21"/>
</svg>
<span id="startStopText">Start</span>
</button>
<button class="btn btn-secondary btn-icon" id="lapBtn" aria-label="Record lap" disabled>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/>
<polyline points="12,6 12,12 16,14"/>
</svg>
</button>
<button class="btn btn-danger btn-icon" id="resetBtn" aria-label="Reset stopwatch">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/>
<path d="M3 3v5h5"/>
</svg>
</button>
</div>
<section class="laps-section" aria-label="Lap times">
<div class="laps-header">
<span class="laps-title">Laps</span>
<span class="laps-count" id="lapsCount">0 recorded</span>
</div>
<div class="laps-list" id="lapsList" role="list">
<div class="empty-laps">No laps recorded</div>
</div>
</section>
</div>
</main>
<script>
// State
let startTime = 0;
let elapsedTime = 0;
let timerInterval = null;
let isRunning = false;
let isPaused = false;
let laps = [];
let lastLapTime = 0;
// DOM Elements
const timeMain = document.getElementById('timeMain');
const timeMs = document.getElementById('timeMs');
const startStopBtn = document.getElementById('startStopBtn');
const startStopText = document.getElementById('startStopText');
const playIcon = document.getElementById('playIcon');
const lapBtn = document.getElementById('lapBtn');
const resetBtn = document.getElementById('resetBtn');
const statusIndicator = document.getElementById('statusIndicator');
const statusText = document.getElementById('statusText');
const lapsList = document.getElementById('lapsList');
const lapsCount = document.getElementById('lapsCount');
// Format time
function formatTime(ms) {
const totalSeconds = Math.floor(ms / 1000);
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
const centiseconds = Math.floor((ms % 1000) / 10);
const formattedMinutes = String(minutes).padStart(2, '0');
const formattedSeconds = String(seconds).padStart(2, '0');
const formattedMs = '.' + String(centiseconds).padStart(2, '0');
return {
main: `${formattedMinutes}:${formattedSeconds}`,
ms: formattedMs
};
}
// Update display
function updateDisplay() {
const currentTime = Date.now();
elapsedTime = currentTime - startTime;
const formatted = formatTime(elapsedTime);
timeMain.textContent = formatted.main;
timeMs.textContent = formatted.ms;
}
// Start the stopwatch
function start() {
if (isRunning) return;
startTime = Date.now() - elapsedTime;
timerInterval = setInterval(updateDisplay, 10);
isRunning = true;
isPaused = false;
// Update UI
statusIndicator.className = 'status-indicator running';
statusText.textContent = 'Running';
timeMain.classList.add('running');
startStopBtn.classList.remove('paused');
startStopText.textContent = 'Stop';
playIcon.innerHTML = '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>';
lapBtn.disabled = false;
}
// Stop/Pause the stopwatch
function stop() {
if (!isRunning) return;
clearInterval(timerInterval);
timerInterval = null;
isRunning = false;
isPaused = true;
// Update UI
statusIndicator.className = 'status-indicator paused';
statusText.textContent = 'Paused';
timeMain.classList.remove('running');
startStopBtn.classList.add('paused');
startStopText.textContent = 'Resume';
playIcon.innerHTML = '<polygon points="5,3 19,12 5,21"/>';
}
// Toggle start/stop
function toggleStartStop() {
if (isRunning) {
stop();
} else {
start();
}
}
// Reset the stopwatch
function reset() {
clearInterval(timerInterval);
timerInterval = null;
startTime = 0;
elapsedTime = 0;
isRunning = false;
isPaused = false;
laps = [];
lastLapTime = 0;
// Update display
timeMain.textContent = '00:00';
timeMs.textContent = '.00';
// Update UI
statusIndicator.className = 'status-indicator';
statusText.textContent = 'Ready';
timeMain.classList.remove('running');
startStopBtn.classList.remove('paused');
startStopText.textContent = 'Start';
playIcon.innerHTML = '<polygon points="5,3 19,12 5,21"/>';
lapBtn.disabled = true;
lapsList.innerHTML = '<div class="empty-laps">No laps recorded</div>';
lapsCount.textContent = '0 recorded';
}
// Record lap
function recordLap() {
if (!isRunning && laps.length === 0) return;
const currentElapsed = elapsedTime;
const lapDiff = currentElapsed - lastLapTime;
lastLapTime = currentElapsed;
const lapNumber = laps.length + 1;
const totalFormatted = formatTime(currentElapsed);
const diffFormatted = formatTime(lapDiff);
laps.unshift({
number: lapNumber,
time: currentElapsed,
diff: lapDiff
});
renderLaps();
lapsCount.textContent = `${laps.length} recorded`;
}
// Render laps list
function renderLaps() {
if (laps.length === 0) {
lapsList.innerHTML = '<div class="empty-laps">No laps recorded</div>';
return;
}
lapsList.innerHTML = laps.map((lap, index) => `
<div class="lap-item" role="listitem" style="animation-delay: ${index * 0.05}s">
<span class="lap-number">Lap ${lap.number}</span>
<span class="lap-diff">+${formatTime(lap.diff).main}${formatTime(lap.diff).ms}</span>
<span class="lap-time">${formatTime(lap.time).main}${formatTime(lap.time).ms}</span>
</div>
`).join('');
}
// Event listeners
startStopBtn.addEventListener('click', toggleStartStop);
resetBtn.addEventListener('click', reset);
lapBtn.addEventListener('click', recordLap);
// Keyboard shortcuts
document.addEventListener('keydown', (e) => {
if (e.code === 'Space' && e.target === document.body) {
e.preventDefault();
toggleStartStop();
}
if (e.code === 'KeyR' && e.target === document.body) {
reset();
}
if (e.code === 'KeyL' && e.target === document.body) {
if (!lapBtn.disabled) {
recordLap();
}
}
});
</script>
</body>
</html>
Design Highlights
Visual Identity:
- Dark technical aesthetic with a subtle grid background pattern
- Electric green accent (
#00ff88) for running state, amber for paused
- JetBrains Mono for the time display (technical/monospace feel)
- Space Grotesk for UI elements (modern, geometric)
Key Features:
- Start/Stop Toggle - Single button handles start and stop with clear state changes
- Reset - Clears everything back to initial state
- Lap Recording - Track split times with differential display
- Status Indicator - Animated pulsing dot shows current state
Interactions:
- Staggered entrance animations for each UI section
- Pulsing indicator when running
- Color transitions between states (green running, amber paused)
- Smooth button press states with scale transforms
- Lap items slide in with animation
Keyboard Shortcuts:
Space - Start/Stop
R - Reset
L - Record lap
Accessibility:
- Semantic HTML with proper ARIA labels
- Focus-visible states on all buttons
- Respects
prefers-reduced-motion
- Screen reader friendly with
aria-live regions