Pomodoro focus timer
A clean 25/5 focus timer with start, pause, reset, and mode switching in one HTML file.
Source code
1 lines · 2.1 KB<style>*{box-sizing:border-box}body{margin:0;font-family:Inter,system-ui,sans-serif;background:#f6f7fb;color:#172033}button,a{font:inherit}.wrap{width:min(960px,calc(100% - 32px));margin:auto}</style><style>main{min-height:100vh;display:grid;place-items:center;padding:24px;background:#0f172a;color:#f8fafc}.box{width:min(380px,100%);background:#1e293b;border:1px solid #334155;border-radius:22px;padding:32px;text-align:center}.tabs{display:flex;gap:8px;justify-content:center}.tabs button{border:1px solid #475569;background:transparent;color:#cbd5e1;padding:7px 14px;border-radius:99px;cursor:pointer}.tabs button.on{background:#38bdf8;color:#0f172a;border-color:#38bdf8;font-weight:700}.time{font-size:64px;font-weight:800;font-variant-numeric:tabular-nums;margin:28px 0}.actions{display:flex;gap:10px;justify-content:center}.actions button{padding:11px 22px;border-radius:10px;border:0;font-weight:700;cursor:pointer}.go{background:#22c55e;color:#052e16}.reset{background:#334155;color:#f8fafc}</style><main><div class="box"><div class="tabs"><button id="b25" class="on" onclick="setMode(25)">Focus 25m</button><button id="b5" onclick="setMode(5)">Break 5m</button></div><div class="time" id="t">25:00</div><div class="actions"><button class="go" id="run" onclick="toggle()">Start</button><button class="reset" onclick="reset()">Reset</button></div></div></main><script>let mins=25,sec=25*60,timer=null;function draw(){const m=String(Math.floor(sec/60)).padStart(2,"0"),s=String(sec%60).padStart(2,"0");document.getElementById("t").textContent=m+":"+s}function toggle(){const b=document.getElementById("run");if(timer){clearInterval(timer);timer=null;b.textContent="Start";return}b.textContent="Pause";timer=setInterval(()=>{if(sec>0){sec--;draw()}else{clearInterval(timer);timer=null;b.textContent="Start"}},1000)}function reset(){if(timer){clearInterval(timer);timer=null}document.getElementById("run").textContent="Start";sec=mins*60;draw()}function setMode(m){mins=m;document.getElementById("b25").classList.toggle("on",m===25);document.getElementById("b5").classList.toggle("on",m===5);reset()}</script>When this template fits
Use this standalone timer for focused study sessions, writing sprints, or classroom timed exercises when you want a calm, ad-free countdown in one shareable tab.
How the layout works
Mode pills switch between 25-minute focus and 5-minute break intervals above a tabular-numeral clock face, preventing digit jitter as seconds tick down.
What to customize
Adjust the preset minute values, add an optional Web Audio chime when reaching 00:00, and keep the Start / Pause / Reset states unmistakable.
Review before publishing
Test switching modes while running to confirm intervals clear cleanly without overlapping timers, and verify contrast in the dark card surface.
Keep building with context
Compare a related pattern or read a practical guide before adapting this example in the Playground.