Bootstrap 5 Review and Rating Box with Source Filter
A review summary with overall score, review stats, source filter chips, a collapsible write-a-review form and a list of customer reviews.
<section class="wdw-stage">
<div class="container" style="max-width:860px">
<div class="wdw-card overflow-hidden" id="reviews">
<div class="p-4 p-md-5 d-flex flex-wrap align-items-center gap-4 border-bottom">
<div class="rv-score text-center">
<div class="display-5 fw-bold lh-1">4.8</div>
<div class="small opacity-75 mt-1">out of 5</div>
</div>
<div class="d-flex gap-4 flex-grow-1 flex-wrap">
<div><div class="wdw-eyebrow text-body-secondary">All reviews</div><div class="h3 fw-bold mb-0">124</div></div>
<div><div class="wdw-eyebrow text-body-secondary">Positive</div><div class="h3 fw-bold mb-0 text-success">93%</div></div>
<div><div class="wdw-eyebrow text-body-secondary">Response rate</div><div class="h3 fw-bold mb-0">98%</div></div>
</div>
<button type="button" class="btn btn-primary rounded-pill px-4" data-bs-toggle="collapse" data-bs-target="#rvForm" aria-expanded="false" aria-controls="rvForm">Write a review</button>
</div>
<div class="collapse" id="rvForm">
<form class="p-4 p-md-5 bg-body-tertiary border-bottom" id="rvFormEl">
<div class="row g-3">
<div class="col-sm-6"><label for="rvName" class="form-label small fw-semibold">Your name</label><input id="rvName" class="form-control" required placeholder="Jane Doe"></div>
<div class="col-sm-6"><label for="rvRating" class="form-label small fw-semibold">Rating</label>
<select id="rvRating" class="form-select"><option value="5">5 - Excellent</option><option value="4">4 - Very good</option><option value="3">3 - Decent</option><option value="2">2 - Poor</option><option value="1">1 - Terrible</option></select></div>
<div class="col-12"><label for="rvText" class="form-label small fw-semibold">Your review</label><textarea id="rvText" class="form-control" rows="3" required placeholder="Tell others about your experience"></textarea></div>
<div class="col-12 text-end"><button type="submit" class="btn btn-primary rounded-pill px-4">Submit review</button></div>
</div>
</form>
</div>
<div class="px-4 px-md-5 py-3 d-flex flex-wrap gap-2 border-bottom" role="group" aria-label="Filter by source">
<button type="button" class="btn btn-sm rounded-pill rv-chip is-active" data-source="all" aria-pressed="true">All sources <span class="rv-count">124</span></button>
<button type="button" class="btn btn-sm rounded-pill rv-chip" data-source="google" aria-pressed="false">Google <span class="rv-count">52</span></button>
<button type="button" class="btn btn-sm rounded-pill rv-chip" data-source="tripadvisor" aria-pressed="false">Tripadvisor <span class="rv-count">31</span></button>
<button type="button" class="btn btn-sm rounded-pill rv-chip" data-source="facebook" aria-pressed="false">Facebook <span class="rv-count">24</span></button>
<button type="button" class="btn btn-sm rounded-pill rv-chip" data-source="reddit" aria-pressed="false">Reddit <span class="rv-count">17</span></button>
</div>
<div class="rv-list">
<article class="rv-item d-flex gap-3 p-4" data-source="google">
<img class="rounded-circle flex-shrink-0" src="https://i.pravatar.cc/96?img=47" width="48" height="48" alt="Emily Carter">
<div class="flex-grow-1">
<div class="d-flex flex-wrap align-items-center gap-2 mb-1">
<h3 class="h6 fw-bold mb-0 text-body-emphasis">Emily Carter</h3>
<span class="badge rounded-pill text-bg-secondary bg-opacity-10 text-body-secondary text-capitalize">via google</span>
<small class="text-body-secondary ms-sm-auto">30 min ago</small>
</div>
<div class="d-flex align-items-center gap-2 mb-2"><span class="d-inline-flex" role="img" aria-label="5 out of 5"><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg></span><strong class="small">Excellent</strong></div>
<p class="mb-0 text-body-secondary">This dive center is incredibly well organized and is at the top of its game. Instructors were patient and the gear was spotless.</p>
</div>
</article>
<article class="rv-item d-flex gap-3 p-4" data-source="tripadvisor">
<img class="rounded-circle flex-shrink-0" src="https://i.pravatar.cc/96?img=15" width="48" height="48" alt="Jonas Weber">
<div class="flex-grow-1">
<div class="d-flex flex-wrap align-items-center gap-2 mb-1">
<h3 class="h6 fw-bold mb-0 text-body-emphasis">Jonas Weber</h3>
<span class="badge rounded-pill text-bg-secondary bg-opacity-10 text-body-secondary text-capitalize">via tripadvisor</span>
<small class="text-body-secondary ms-sm-auto">2 days ago</small>
</div>
<div class="d-flex align-items-center gap-2 mb-2"><span class="d-inline-flex" role="img" aria-label="5 out of 5"><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg></span><strong class="small">Worth every penny</strong></div>
<p class="mb-0 text-body-secondary">Booked a two-day open water course. Small groups, great briefings, and we saw a turtle on the first dive.</p>
</div>
</article>
<article class="rv-item d-flex gap-3 p-4" data-source="facebook">
<img class="rounded-circle flex-shrink-0" src="https://i.pravatar.cc/96?img=45" width="48" height="48" alt="Mia Alvarez">
<div class="flex-grow-1">
<div class="d-flex flex-wrap align-items-center gap-2 mb-1">
<h3 class="h6 fw-bold mb-0 text-body-emphasis">Mia Alvarez</h3>
<span class="badge rounded-pill text-bg-secondary bg-opacity-10 text-body-secondary text-capitalize">via facebook</span>
<small class="text-body-secondary ms-sm-auto">1 week ago</small>
</div>
<div class="d-flex align-items-center gap-2 mb-2"><span class="d-inline-flex" role="img" aria-label="4 out of 5"><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star off" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg></span><strong class="small">Very good</strong></div>
<p class="mb-0 text-body-secondary">Friendly crew and well-run boat trips. Only downside was the early start, but the reef made up for it.</p>
</div>
</article>
<article class="rv-item d-flex gap-3 p-4" data-source="reddit">
<img class="rounded-circle flex-shrink-0" src="https://i.pravatar.cc/96?img=13" width="48" height="48" alt="Tom Fischer">
<div class="flex-grow-1">
<div class="d-flex flex-wrap align-items-center gap-2 mb-1">
<h3 class="h6 fw-bold mb-0 text-body-emphasis">Tom Fischer</h3>
<span class="badge rounded-pill text-bg-secondary bg-opacity-10 text-body-secondary text-capitalize">via reddit</span>
<small class="text-body-secondary ms-sm-auto">2 weeks ago</small>
</div>
<div class="d-flex align-items-center gap-2 mb-2"><span class="d-inline-flex" role="img" aria-label="3 out of 5"><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star off" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg><svg class="rv-star off" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3 6.1 20.6l1.3-6.6L2.5 9.4l6.6-.8z"/></svg></span><strong class="small">Decent</strong></div>
<p class="mb-0 text-body-secondary">Good equipment and safety standards. Gets crowded on weekends, so book a weekday if you can.</p>
</div>
</article>
</div>
<p class="text-center text-body-secondary small m-0 p-4 d-none" id="rvEmpty">No reviews for this source yet.</p>
</div>
</div>
</section>
/* Web Designer Wall library style — shared base for every Bootstrap 5 snippet.
Indigo accent, Plus Jakarta Sans, soft cards, pill buttons. Works in light and dark. */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");
:root,
[data-bs-theme="light"] {
--wdw-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--bs-body-font-family: var(--wdw-font);
--bs-primary: #4f46e5;
--bs-primary-rgb: 79, 70, 229;
--bs-primary-text-emphasis: #3730a3;
--bs-primary-bg-subtle: #eef2ff;
--bs-primary-border-subtle: #c7d2fe;
--bs-link-color: #4f46e5;
--bs-link-color-rgb: 79, 70, 229;
--bs-link-hover-color: #4338ca;
--bs-link-hover-color-rgb: 67, 56, 202;
--bs-focus-ring-color: rgba(79, 70, 229, 0.25);
--bs-border-radius: 0.75rem;
--bs-border-radius-lg: 1rem;
--bs-border-radius-xl: 1.25rem;
--wdw-radius-card: 1.25rem;
--wdw-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px -16px rgba(16, 24, 40, 0.22);
--wdw-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -4px rgba(16, 24, 40, 0.12);
--wdw-stage: #f5f6fb;
}
[data-bs-theme="dark"] {
--bs-primary: #818cf8;
--bs-primary-rgb: 129, 140, 248;
--bs-primary-text-emphasis: #c7d2fe;
--bs-primary-bg-subtle: rgba(129, 140, 248, 0.14);
--bs-primary-border-subtle: rgba(129, 140, 248, 0.35);
--bs-link-color: #a5b4fc;
--bs-link-color-rgb: 165, 180, 252;
--bs-link-hover-color: #c7d2fe;
--bs-link-hover-color-rgb: 199, 210, 254;
--bs-focus-ring-color: rgba(129, 140, 248, 0.35);
--wdw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
--wdw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
--wdw-stage: #0f1117;
}
body { font-family: var(--wdw-font); -webkit-font-smoothing: antialiased; }
/* Bootstrap compiles its blue into these components; point them at the accent. */
.btn-primary {
--bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca;
--bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3;
--bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1117; --bs-btn-hover-bg: #a5b4fc; --bs-btn-hover-border-color: #a5b4fc; --bs-btn-hover-color: #0f1117; --bs-btn-active-color: #0f1117; }
.btn-outline-primary {
--bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary);
--bs-btn-active-bg: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn { --bs-btn-font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.btn-sm { min-height: 36px; }
.form-control, .form-select { min-height: 44px; border-radius: .75rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--bs-primary-rgb), .6); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--bs-primary); border-color: var(--bs-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.nav { --bs-nav-link-color: var(--bs-secondary-color); --bs-nav-link-hover-color: var(--bs-emphasis-color); }
.pagination { --bs-pagination-active-bg: var(--bs-primary); --bs-pagination-active-border-color: var(--bs-primary); --bs-pagination-color: var(--bs-body-color); --bs-pagination-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--bs-primary); }
.list-group { --bs-list-group-active-bg: var(--bs-primary); --bs-list-group-active-border-color: var(--bs-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); border-radius: .875rem; box-shadow: var(--wdw-shadow-sm); }
.accordion { --bs-accordion-active-bg: var(--bs-primary-bg-subtle); --bs-accordion-active-color: var(--bs-primary-text-emphasis); --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.badge { font-weight: 600; }
/* Library building blocks — use these instead of re-inventing them per snippet. */
.wdw-stage { min-height: 100vh; display: flex; align-items: center; background: var(--wdw-stage); padding-block: 3rem; }
.wdw-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: var(--wdw-radius-card); box-shadow: var(--wdw-shadow); }
.wdw-card-sm { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: 1rem; box-shadow: var(--wdw-shadow-sm); }
.wdw-aurora { position: relative; color: #fff; background: radial-gradient(60% 55% at 100% 0, #818cf8 0, transparent 70%), radial-gradient(65% 60% at 0 100%, #ec4899 0, transparent 65%), #1e1b4b; }
.wdw-eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-primary); }
.wdw-heading { font-weight: 800; letter-spacing: -.02em; color: var(--bs-emphasis-color); }
.wdw-muted { color: var(--bs-secondary-color); }
.wdw-icon { width: 2.75rem; height: 2.75rem; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: .875rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }
/* Component */
.rv-score { background: var(--bs-primary); color: #fff; border-radius: 1rem; padding: 1rem 1.5rem; min-width: 110px; }
[data-bs-theme="dark"] .rv-score { color: #0f1117; }
.rv-chip { --bs-btn-color: var(--bs-body-color); border: 1px solid var(--bs-border-color); background: transparent; }
.rv-chip:hover { background: var(--bs-tertiary-bg); }
.rv-chip.is-active { background: var(--bs-primary-bg-subtle); border-color: var(--bs-primary-border-subtle); color: var(--bs-primary-text-emphasis); }
.rv-count { opacity: .6; font-weight: 500; margin-left: .15rem; }
.rv-star { fill: #f59e0b; }
.rv-star.off { fill: var(--bs-border-color); }
.rv-item + .rv-item { border-top: 1px solid var(--bs-border-color-translucent); }
.rv-item[hidden] { display: none !important; }
@media (min-width: 768px) { .rv-item { padding-inline: 3rem !important; } }
(function () {
function initFilter() {
var root = document.getElementById('reviews');
if (!root) return;
var chips = root.querySelectorAll('.rv-chip'), empty = document.getElementById('rvEmpty');
chips.forEach(function (chip) {
chip.addEventListener('click', function () {
chips.forEach(function (c) { c.classList.remove('is-active'); c.setAttribute('aria-pressed', 'false'); });
chip.classList.add('is-active'); chip.setAttribute('aria-pressed', 'true');
var src = chip.dataset.source, shown = 0;
root.querySelectorAll('.rv-item').forEach(function (it) {
var ok = src === 'all' || it.dataset.source === src;
it.hidden = !ok; if (ok) shown++;
});
empty.classList.toggle('d-none', shown > 0);
});
});
}
function initForm() {
var form = document.getElementById('rvFormEl');
if (!form) return;
form.addEventListener('submit', function (e) {
e.preventDefault();
var list = document.querySelector('.rv-list'), first = list.querySelector('.rv-item');
var node = first.cloneNode(true), n = form.rvName.value.trim(), r = +form.rvRating.value;
node.dataset.source = 'google'; node.hidden = false;
node.querySelector('h3').textContent = n;
node.querySelector('img').alt = n;
node.querySelector('small').textContent = 'Just now';
node.querySelector('.badge').textContent = 'via google';
node.querySelectorAll('.rv-star').forEach(function (s, i) { s.classList.toggle('off', i >= r); });
node.querySelector('[role=img]').setAttribute('aria-label', r + ' out of 5');
node.querySelector('strong.small').textContent = ['', 'Terrible', 'Poor', 'Decent', 'Very good', 'Excellent'][r];
node.querySelector('p').textContent = form.rvText.value.trim();
list.prepend(node);
form.reset();
bootstrap.Collapse.getOrCreateInstance(document.getElementById('rvForm')).hide();
});
}
initFilter(); initForm();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.