LMS — Progress Ring
A self-contained set of progress meters for e-learning interfaces. The centerpiece is an animated SVG circular ring with a gradient stroke and a count-up percentage at its core, paired with quick-set buttons that re-draw the fill and update the lesson tally. Alongside it sit a linear XP and level meter that handles level-ups, plus a responsive grid of per-module cards combining mini progress rings, linear bars, completion pills, and a friendly toast helper.
MCP
Code
:root {
--brand: #5b5bd6;
--brand-d: #4444c2;
--brand-50: #eeeefc;
--accent: #13b981;
--amber: #f59e0b;
--ink: #1a1a2e;
--ink-2: #44465f;
--muted: #6b6e87;
--bg: #f7f7fb;
--surface: #ffffff;
--line: rgba(26, 26, 46, 0.1);
--ok: #13b981;
--danger: #e05656;
--r-sm: 8px;
--r-md: 14px;
--r-lg: 20px;
--sh-sm: 0 1px 2px rgba(26, 26, 46, 0.06), 0 1px 3px rgba(26, 26, 46, 0.05);
--sh-md: 0 8px 24px rgba(26, 26, 46, 0.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
margin: 0;
font-family: "Inter", system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--ink);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
button { font-family: inherit; }
.page { max-width: 920px; margin: 0 auto; padding: 22px 18px 56px; }
/* Topbar */
.topbar {
display: flex; align-items: center; justify-content: space-between;
gap: 14px; margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
width: 40px; height: 40px; display: grid; place-items: center;
border-radius: var(--r-md); font-size: 22px; color: #fff;
background: linear-gradient(135deg, var(--brand), var(--accent));
box-shadow: var(--sh-sm);
}
.topbar h1 { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.sub { font-size: 13px; color: var(--muted); }
.learner { display: flex; align-items: center; gap: 10px; }
.lvl-pill {
display: inline-flex; align-items: center; gap: 6px;
font-size: 12.5px; font-weight: 700; color: var(--brand-d);
background: var(--brand-50); padding: 6px 11px; border-radius: 999px;
}
.lvl-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.avatar {
width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
font-size: 13px; font-weight: 700; color: #fff;
background: linear-gradient(135deg, #7b7be6, var(--brand-d));
}
.card {
background: var(--surface); border: 1px solid var(--line);
border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
/* Hero */
.hero {
display: flex; gap: 28px; align-items: center; padding: 26px;
margin-bottom: 18px;
}
.ring-wrap { position: relative; width: 180px; height: 180px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--brand-50); stroke-width: 11; }
.ring-fill {
fill: none; stroke: url(#ringGrad); stroke-width: 11; stroke-linecap: round;
stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-center {
position: absolute; inset: 0; display: grid; place-content: center;
text-align: center;
}
.ring-pct { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); }
.ring-pct .unit { font-size: 20px; font-weight: 700; color: var(--muted); margin-left: 1px; }
.ring-lbl {
display: block; font-size: 12px; font-weight: 600; text-transform: uppercase;
letter-spacing: 0.08em; color: var(--muted); margin-top: 2px;
}
.hero-body { min-width: 0; }
.hero-body h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.015em; }
.hero-note { color: var(--ink-2); font-size: 14px; margin-top: 6px; max-width: 46ch; }
.hero-stats { display: flex; gap: 22px; margin: 16px 0 18px; }
.stat { display: flex; flex-direction: column; }
.stat-n { font-size: 17px; font-weight: 800; color: var(--ink); }
.stat-l { font-size: 12px; color: var(--muted); }
.setters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.setters-lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-right: 2px; }
.chip {
border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 999px;
cursor: pointer; transition: transform 0.12s, border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand-d); transform: translateY(-1px); }
.chip:active { transform: translateY(0); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.ghost { background: var(--brand-50); border-color: transparent; color: var(--brand-d); }
.chip.ghost:hover { background: #e3e3fa; }
.chip:focus-visible, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* XP card */
.xp-card { padding: 20px 24px; margin-bottom: 22px; }
.xp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.xp-head h2 { font-size: 16px; font-weight: 700; }
.diff-pill {
font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.diff-pill.easy { color: #0f7a55; background: #d9f5ea; }
.xp-row { display: flex; align-items: center; gap: 16px; }
.xp-badge {
flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
font-size: 14px; font-weight: 800; color: #fff;
background: linear-gradient(135deg, var(--amber), #f97316);
box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}
.xp-meter { flex: 1; min-width: 0; }
.xp-bar { height: 12px; background: var(--brand-50); border-radius: 999px; overflow: hidden; }
.xp-fill {
display: block; height: 100%; width: 0%;
background: linear-gradient(90deg, var(--brand), var(--accent));
border-radius: 999px; transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.xp-meta { display: flex; justify-content: space-between; font-size: 12.5px; margin-top: 7px; }
.xp-meta span:first-child { font-weight: 700; color: var(--ink); }
.xp-meta span:last-child { color: var(--muted); }
/* Section head */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 14px; }
.section-head h2 { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }
/* Module grid */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.mod {
background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
padding: 16px; box-shadow: var(--sh-sm); transition: box-shadow 0.18s, transform 0.18s;
}
.mod:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.mod-top { display: flex; align-items: center; gap: 12px; }
.mod-ring { width: 56px; height: 56px; flex: none; position: relative; }
.mod-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.mr-track { fill: none; stroke: var(--brand-50); stroke-width: 7; }
.mr-fill {
fill: none; stroke-width: 7; stroke-linecap: round;
stroke-dasharray: 144.5; stroke-dashoffset: 144.5;
transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.mod-ring .mr-pct {
position: absolute; inset: 0; display: grid; place-content: center;
font-size: 13px; font-weight: 800;
}
.mod-info { min-width: 0; }
.mod-info h3 { font-size: 14.5px; font-weight: 700; }
.mod-info .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mod-bar { height: 8px; background: var(--brand-50); border-radius: 999px; overflow: hidden; margin-top: 14px; }
.mod-bar span {
display: block; height: 100%; width: 0%; border-radius: 999px;
transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.mod-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.mod-foot .done-pill {
font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
color: var(--accent); background: #d9f5ea;
}
.mod-foot .in-pill {
font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
color: var(--brand-d); background: var(--brand-50);
}
.mod-foot .lsn { font-size: 12px; color: var(--muted); }
.foot { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 30px; }
/* Toast */
.toast {
position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 600;
padding: 11px 18px; border-radius: 999px; box-shadow: var(--sh-md);
opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 640px) {
.hero { flex-direction: column; text-align: center; padding: 22px; }
.hero-note { max-width: none; }
.hero-stats { justify-content: center; }
.setters { justify-content: center; }
}
@media (max-width: 520px) {
.page { padding: 16px 13px 44px; }
.topbar h1 { font-size: 17px; }
.ring-wrap { width: 158px; height: 158px; }
.ring-pct { font-size: 34px; }
.hero-stats { gap: 16px; }
.xp-row { flex-wrap: wrap; }
.xp-meter { order: 3; flex-basis: 100%; }
.mod-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
.ring-fill, .mr-fill, .xp-fill, .mod-bar span { transition: none; }
}(function () {
"use strict";
var TOTAL_LESSONS = 20;
// ---- Toast helper ----
var toastEl = document.getElementById("toast");
var toastTimer;
function toast(msg) {
if (!toastEl) return;
toastEl.textContent = msg;
toastEl.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(function () {
toastEl.classList.remove("show");
}, 2200);
}
function clamp(n) { return Math.max(0, Math.min(100, n)); }
// ---- Hero ring ----
var HERO_CIRC = 2 * Math.PI * 52; // r=52
var heroFill = document.getElementById("heroFill");
var heroPct = document.getElementById("heroPct");
var statLessons = document.getElementById("statLessons");
var chips = Array.prototype.slice.call(document.querySelectorAll(".chip[data-set]"));
var heroValue = 0;
function renderHero(pct) {
heroValue = clamp(Math.round(pct));
heroFill.style.strokeDashoffset = HERO_CIRC * (1 - heroValue / 100);
// count-up the centre number
animateNumber(heroPct, heroValue, function (v) {
heroPct.innerHTML = v + '<span class="unit">%</span>';
});
var lessons = Math.round((heroValue / 100) * TOTAL_LESSONS);
statLessons.textContent = lessons + "/" + TOTAL_LESSONS;
chips.forEach(function (c) {
c.classList.toggle("active", parseInt(c.dataset.set, 10) === heroValue);
});
}
function animateNumber(el, target, render) {
var start = parseInt(el.textContent, 10) || 0;
if (start === target) { render(target); return; }
var dur = 600, t0 = performance.now();
function step(now) {
var p = Math.min(1, (now - t0) / dur);
var eased = 1 - Math.pow(1 - p, 3);
render(Math.round(start + (target - start) * eased));
if (p < 1) requestAnimationFrame(step);
}
requestAnimationFrame(step);
}
chips.forEach(function (chip) {
chip.addEventListener("click", function () {
var v = parseInt(chip.dataset.set, 10);
renderHero(v);
toast(v === 100 ? "Course complete — nice work!" : "Progress set to " + v + "%");
});
});
document.getElementById("addLesson").addEventListener("click", function () {
var next = Math.min(100, heroValue + Math.round((1 / TOTAL_LESSONS) * 100) + (heroValue % 5 === 0 ? 0 : 0));
var lessons = Math.min(TOTAL_LESSONS, Math.round((heroValue / 100) * TOTAL_LESSONS) + 1);
next = Math.round((lessons / TOTAL_LESSONS) * 100);
renderHero(next);
if (lessons >= TOTAL_LESSONS) toast("All " + TOTAL_LESSONS + " lessons done!");
else toast("Lesson " + lessons + " checked off · +1");
});
// ---- XP / level meter ----
var XP_PER_LEVEL = 2400;
var xpFill = document.getElementById("xpFill");
var xpText = document.getElementById("xpText");
var xpNext = document.getElementById("xpNext");
var xpLevel = document.getElementById("xpLevel");
var level = 7;
var xp = 1850;
function fmt(n) { return n.toLocaleString("en-US").replace(/,/g, " "); }
function renderXp() {
var pct = clamp((xp / XP_PER_LEVEL) * 100);
xpFill.style.width = pct + "%";
xpText.textContent = fmt(xp) + " / " + fmt(XP_PER_LEVEL) + " XP";
xpNext.textContent = fmt(XP_PER_LEVEL - xp) + " XP to Level " + (level + 1);
xpLevel.textContent = "Lv " + level;
}
document.getElementById("earnXp").addEventListener("click", function () {
xp += 120;
if (xp >= XP_PER_LEVEL) {
xp -= XP_PER_LEVEL;
level += 1;
renderXp();
toast("Level up! You reached Level " + level + " 🎉");
return;
}
renderXp();
toast("+120 XP earned");
});
// ---- Module rings ----
var MODULES = [
{ name: "HTML & Semantics", lessons: 4, done: 4, pct: 100 },
{ name: "CSS Layout", lessons: 5, done: 5, pct: 100 },
{ name: "Flexbox & Grid", lessons: 4, done: 3, pct: 75 },
{ name: "JavaScript Basics", lessons: 4, done: 2, pct: 50 },
{ name: "DOM & Events", lessons: 3, done: 0, pct: 12 }
];
var MR_CIRC = 2 * Math.PI * 23; // r=23
function colorFor(pct) {
if (pct >= 100) return "var(--accent)";
if (pct >= 50) return "var(--brand)";
return "var(--amber)";
}
function buildModules() {
var grid = document.getElementById("modGrid");
MODULES.forEach(function (m, i) {
var col = colorFor(m.pct);
var pillClass = m.pct >= 100 ? "done-pill" : "in-pill";
var pillText = m.pct >= 100 ? "Completed" : "In progress";
var el = document.createElement("article");
el.className = "mod";
el.innerHTML =
'<div class="mod-top">' +
'<div class="mod-ring">' +
'<svg viewBox="0 0 56 56" aria-hidden="true">' +
'<circle class="mr-track" cx="28" cy="28" r="23"></circle>' +
'<circle class="mr-fill" cx="28" cy="28" r="23" style="stroke:' + col + '"></circle>' +
'</svg>' +
'<span class="mr-pct" style="color:' + col + '">' + m.pct + '%</span>' +
'</div>' +
'<div class="mod-info">' +
'<h3>' + m.name + '</h3>' +
'<div class="meta">Module ' + (i + 1) + ' · ' + m.lessons + ' lessons</div>' +
'</div>' +
'</div>' +
'<div class="mod-bar"><span style="background:' + col + '"></span></div>' +
'<div class="mod-foot">' +
'<span class="' + pillClass + '">' + pillText + '</span>' +
'<span class="lsn">' + m.done + '/' + m.lessons + ' lessons</span>' +
'</div>';
grid.appendChild(el);
// animate in on next frame
requestAnimationFrame(function () {
var fill = el.querySelector(".mr-fill");
var bar = el.querySelector(".mod-bar span");
setTimeout(function () {
fill.style.strokeDashoffset = MR_CIRC * (1 - m.pct / 100);
bar.style.width = m.pct + "%";
}, 80 + i * 90);
});
});
}
// ---- Init ----
buildModules();
renderXp();
// kick off hero animation shortly after load
setTimeout(function () { renderHero(70); }, 200);
})();<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>LMS — Progress Ring</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=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="page">
<header class="topbar">
<div class="brand">
<span class="brand-mark" aria-hidden="true">◓</span>
<div>
<h1>Course Progress</h1>
<p class="sub">Frontend Foundations · Spring cohort</p>
</div>
</div>
<div class="learner">
<span class="lvl-pill"><span class="dot" aria-hidden="true"></span>Level 7</span>
<span class="avatar" aria-hidden="true">MR</span>
</div>
</header>
<main>
<!-- Hero ring -->
<section class="hero card" aria-labelledby="hero-title">
<div class="ring-wrap">
<svg class="ring" viewBox="0 0 120 120" role="img" aria-labelledby="ringTitle ringDesc">
<title id="ringTitle">Overall course completion</title>
<desc id="ringDesc">Animated circular progress meter</desc>
<defs>
<linearGradient id="ringGrad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#5b5bd6" />
<stop offset="100%" stop-color="#13b981" />
</linearGradient>
</defs>
<circle class="ring-track" cx="60" cy="60" r="52" />
<circle class="ring-fill" id="heroFill" cx="60" cy="60" r="52" />
</svg>
<div class="ring-center">
<span class="ring-pct" id="heroPct" aria-live="polite">0<span class="unit">%</span></span>
<span class="ring-lbl">complete</span>
</div>
</div>
<div class="hero-body">
<h2 id="hero-title">You're making real progress</h2>
<p class="hero-note">14 of 20 lessons checked off across 5 modules. Keep a steady pace to finish before the cohort review.</p>
<div class="hero-stats">
<div class="stat"><span class="stat-n" id="statLessons">14/20</span><span class="stat-l">Lessons</span></div>
<div class="stat"><span class="stat-n">6h 12m</span><span class="stat-l">Time spent</span></div>
<div class="stat"><span class="stat-n">9</span><span class="stat-l">Day streak</span></div>
</div>
<div class="setters" role="group" aria-label="Set overall progress">
<span class="setters-lbl">Jump to:</span>
<button class="chip" data-set="0">0%</button>
<button class="chip" data-set="25">25%</button>
<button class="chip" data-set="50">50%</button>
<button class="chip" data-set="70">70%</button>
<button class="chip" data-set="100">100%</button>
<button class="chip ghost" id="addLesson">+ Complete lesson</button>
</div>
</div>
</section>
<!-- XP / level meter -->
<section class="card xp-card" aria-labelledby="xp-title">
<div class="xp-head">
<h2 id="xp-title">Experience & level</h2>
<span class="diff-pill easy">On track</span>
</div>
<div class="xp-row">
<span class="xp-badge" id="xpLevel">Lv 7</span>
<div class="xp-meter">
<div class="xp-bar"><span class="xp-fill" id="xpFill"></span></div>
<div class="xp-meta">
<span id="xpText">1 850 / 2 400 XP</span>
<span id="xpNext">550 XP to Level 8</span>
</div>
</div>
<button class="chip ghost" id="earnXp">+120 XP</button>
</div>
</section>
<!-- Module rings -->
<section aria-labelledby="mods-title">
<div class="section-head">
<h2 id="mods-title">Modules</h2>
<span class="muted">5 modules · linear & ring meters</span>
</div>
<div class="mod-grid" id="modGrid"><!-- injected --></div>
</section>
</main>
<footer class="foot">Illustrative UI — fictional courses, not a real learning platform.</footer>
</div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<script src="script.js"></script>
</body>
</html>Progress Ring
A friendly completion meter built for a focused-reading LMS. The hero is a large SVG progress ring with a brand-to-success gradient stroke and rounded line caps; its center holds a bold count-up percentage and a “complete” label. A row of quick-set chips snaps the ring to 0, 25, 50, 70 or 100 percent, animating the stroke offset while the lesson tally and active chip stay in sync. A “complete lesson” button advances progress one lesson at a time and confirms each step with a toast.
Below the hero, a linear XP and level meter fills a gradient bar toward the next level. The “+120 XP” button accumulates points, rolls the bar over on a level-up, and bumps the level badge with a celebratory toast. The remaining-XP caption recalculates on every tap.
A responsive grid of module cards rounds it out. Each card pairs a small progress ring with a linear bar, color-coded amber, brand or green by completion, and shows a completed or in-progress pill with its lessons-done count. Rings and bars animate in on load with a slight stagger, and the whole layout collapses gracefully down to a narrow mobile column. Motion is disabled for users who prefer reduced motion.
Illustrative UI only — fictional courses, not a real learning platform.