Bootstrap 5 Post Card with Like, Comment and Share
A social post card with a photo, reaction summary and like, comment and share actions; comments expand beneath it, new comments can be posted and the link can be copied.
<section class="wdw-stage">
<div class="container" style="max-width:680px">
<article class="wdw-card p-4">
<header class="d-flex align-items-center gap-3 mb-3">
<img src="https://i.pravatar.cc/100?img=47" width="48" height="48" class="rounded-circle" alt="Marry Andrews">
<div class="lh-sm"><strong class="text-body-emphasis d-block">Marry Andrews</strong><small class="wdw-muted">Shared publicly · Jan 2026</small></div>
</header>
<p class="mb-4">Finished the new design system audit today. Fewer tokens, clearer names, and every component finally has a dark mode that works. Happy to share the checklist if it helps.</p>
<img src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?auto=format&fit=crop&w=1200&q=70" class="img-fluid rounded-4 w-100 mb-3 wdw-photo" width="1200" height="520" alt="Team reviewing design work together around a table">
<div class="d-flex justify-content-between align-items-center small wdw-muted mb-2">
<span class="d-flex align-items-center gap-2"><span class="d-flex wdw-stack" aria-hidden="true"><img src="https://i.pravatar.cc/60?img=12" alt=""><img src="https://i.pravatar.cc/60?img=32" alt=""><img src="https://i.pravatar.cc/60?img=5" alt=""></span><span id="likeCount">24 likes</span></span>
<span id="cmtCount">2 comments</span>
</div>
<div class="d-flex gap-2 border-top pt-2">
<button class="btn flex-fill rounded-pill wdw-act" type="button" id="likeBtn" aria-pressed="false">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8l1 1.1L12 21l7.8-7.5 1-1.1a5.5 5.5 0 0 0 0-7.8z"/></svg>Like</button>
<button class="btn flex-fill rounded-pill wdw-act" type="button" data-bs-toggle="collapse" data-bs-target="#cmtBox" aria-expanded="false" aria-controls="cmtBox">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>Comment</button>
<button class="btn flex-fill rounded-pill wdw-act" type="button" data-bs-toggle="collapse" data-bs-target="#shareBox" aria-expanded="false" aria-controls="shareBox">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><path d="M8.6 13.5l6.8 4M15.4 6.5l-6.8 4"/></svg>Share</button>
</div>
<div id="cmtParent">
<div id="cmtBox" class="collapse" data-bs-parent="#cmtParent">
<ul class="list-unstyled d-grid gap-3 pt-3 mb-3" id="cmtList">
<li class="d-flex gap-2"><img src="https://i.pravatar.cc/80?img=12" width="36" height="36" class="rounded-circle" alt=""><div class="bg-body-tertiary rounded-4 px-3 py-2"><strong class="small d-block">Tom Reyes</strong><span class="small">Yes please, send it over!</span></div></li>
<li class="d-flex gap-2"><img src="https://i.pravatar.cc/80?img=32" width="36" height="36" class="rounded-circle" alt=""><div class="bg-body-tertiary rounded-4 px-3 py-2"><strong class="small d-block">Lena Park</strong><span class="small">Dark mode on every component is the dream.</span></div></li>
</ul>
<form id="cmtForm" class="d-flex gap-2">
<label class="visually-hidden" for="cmtInput">Write a comment</label>
<input id="cmtInput" class="form-control rounded-pill" placeholder="Write a comment…" required>
<button class="btn btn-primary rounded-pill px-4" type="submit">Post</button>
</form>
</div>
<div id="shareBox" class="collapse" data-bs-parent="#cmtParent"><div class="d-flex flex-wrap gap-2 pt-3"><button class="btn btn-outline-primary btn-sm rounded-pill" type="button" data-copy>Copy link</button><button class="btn btn-outline-secondary btn-sm rounded-pill" type="button" data-toast="Sent in a message">Send in message</button><button class="btn btn-outline-secondary btn-sm rounded-pill" type="button" data-toast="Shared to your feed">Share to feed</button></div></div>
</div>
</article>
<div class="toast-container position-fixed bottom-0 start-50 translate-middle-x p-3">
<div id="shareToast" class="toast align-items-center text-bg-dark border-0" role="status" aria-live="polite" aria-atomic="true">
<div class="d-flex"><div class="toast-body" id="toastMsg">Done</div><button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button></div>
</div>
</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 */
.wdw-act { --bs-btn-color: var(--bs-secondary-color); --bs-btn-hover-color: var(--bs-emphasis-color); --bs-btn-hover-bg: var(--bs-tertiary-bg); --bs-btn-hover-border-color: transparent; --bs-btn-border-color: transparent; --bs-btn-active-color: var(--bs-primary); --bs-btn-active-bg: var(--bs-primary-bg-subtle); --bs-btn-active-border-color: transparent; font-weight: 600; }
.wdw-act[aria-expanded="true"], .wdw-act[aria-pressed="true"] { --bs-btn-color: var(--bs-primary); --bs-btn-bg: var(--bs-primary-bg-subtle); --bs-btn-hover-color: var(--bs-primary); --bs-btn-hover-bg: var(--bs-primary-bg-subtle); }
.wdw-act[aria-pressed="true"] svg { fill: currentColor; }
.wdw-photo { aspect-ratio: 21 / 9; object-fit: cover; }
.wdw-stack img { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--bs-body-bg); object-fit: cover; }
.wdw-stack img + img { margin-left: -8px; }
(function () {
function initLike() {
var btn = document.getElementById('likeBtn'), out = document.getElementById('likeCount');
if (!btn || !out) return;
var n = 24;
btn.addEventListener('click', function () {
var on = btn.getAttribute('aria-pressed') !== 'true';
btn.setAttribute('aria-pressed', on);
out.textContent = (n + (on ? 1 : 0)) + ' likes';
});
}
function initComments() {
var form = document.getElementById('cmtForm'), list = document.getElementById('cmtList'), count = document.getElementById('cmtCount');
if (!form || !list) return;
form.addEventListener('submit', function (e) {
e.preventDefault();
var input = document.getElementById('cmtInput');
var text = input.value.trim();
if (!text) return;
var li = document.createElement('li');
li.className = 'd-flex gap-2';
var box = document.createElement('div');
box.className = 'bg-body-tertiary rounded-4 px-3 py-2';
var name = document.createElement('strong'); name.className = 'small d-block'; name.textContent = 'You';
var msg = document.createElement('span'); msg.className = 'small'; msg.textContent = text;
box.append(name, msg);
li.innerHTML = '<span class="wdw-icon rounded-circle" style="width:36px;height:36px;font-size:.75rem;font-weight:700">Y</span>';
li.appendChild(box);
list.appendChild(li);
count.textContent = list.children.length + ' comments';
input.value = '';
});
}
function initShare() {
var el = document.getElementById('shareToast'), msg = document.getElementById('toastMsg');
if (!el || !msg) return;
var toast = bootstrap.Toast.getOrCreateInstance(el, { delay: 2200 });
function show(text) { msg.textContent = text; toast.show(); }
var copy = document.querySelector('[data-copy]');
if (copy) copy.addEventListener('click', function () {
var done = function (ok) { show(ok ? 'Link copied to clipboard' : 'Could not copy the link'); };
try { navigator.clipboard.writeText(location.href).then(function () { done(true); }, function () { done(false); }); }
catch (err) { done(false); }
});
document.querySelectorAll('[data-toast]').forEach(function (b) {
b.addEventListener('click', function () { show(b.dataset.toast); });
});
}
initLike(); initComments(); initShare();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.