Bootstrap 5 Social Media Feed Post with Comments
A social feed post with author, photo, like and share actions, a comment thread and an input that adds new comments.
<section class="wdw-stage">
<div class="container" style="max-width: 680px">
<article class="wdw-card overflow-hidden">
<header class="d-flex align-items-center gap-3 p-3 px-4">
<img src="https://i.pravatar.cc/96?img=12" alt="" width="44" height="44" class="rounded-circle">
<div class="me-auto lh-sm">
<a href="#" class="fw-bold text-body-emphasis text-decoration-none">Henry German</a>
<div class="small wdw-muted">Public · 2h</div>
</div>
<div class="dropdown">
<button class="btn btn-sm bg-body-secondary rounded-circle p-0 sf-round" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Post options">
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg>
</button>
<ul class="dropdown-menu dropdown-menu-end"><li><a class="dropdown-item" href="#">Save post</a></li><li><a class="dropdown-item" href="#">Copy link</a></li><li><a class="dropdown-item text-danger" href="#">Report</a></li></ul>
</div>
</header>
<p class="px-4 mb-3">Look at the beach photo I clicked at golden hour.</p>
<img src="https://images.unsplash.com/photo-1507525428034-b723cf961d3e?auto=format&fit=crop&w=1100&q=80" alt="Sunset over a calm beach with a glowing sky" class="w-100 h-auto object-fit-cover sf-photo">
<div class="d-flex align-items-center gap-2 px-4 pt-3 small wdw-muted">
<span class="d-flex sf-stack" aria-hidden="true">
<img src="https://i.pravatar.cc/48?img=47" alt="" width="24" height="24" class="rounded-circle">
<img src="https://i.pravatar.cc/48?img=15" alt="" width="24" height="24" class="rounded-circle">
<img src="https://i.pravatar.cc/48?img=32" alt="" width="24" height="24" class="rounded-circle">
</span>
<span><span id="sfLikes">127</span> likes</span>
<span class="ms-auto"><a href="#" class="link-secondary link-underline-opacity-0 link-underline-opacity-100-hover" id="sfViewAll">View all <span id="sfCount">14</span> comments</a></span>
</div>
<div class="d-flex align-items-center gap-2 px-4 py-3 border-bottom">
<div class="sf-like-wrap position-relative">
<div class="sf-react bg-body wdw-card-sm d-flex gap-1 p-1 rounded-pill" role="group" aria-label="Reactions">
<button type="button" class="btn btn-sm btn-light rounded-circle p-0 sf-emoji" data-react="Like" aria-label="React with Like">👍</button>
<button type="button" class="btn btn-sm btn-light rounded-circle p-0 sf-emoji" data-react="Love" aria-label="React with Love">❤️</button>
<button type="button" class="btn btn-sm btn-light rounded-circle p-0 sf-emoji" data-react="Wow" aria-label="React with Wow">😮</button>
</div>
<button type="button" class="btn btn-sm btn-outline-secondary rounded-pill px-3" id="sfLike" aria-pressed="false">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20.8 5.6a5.2 5.2 0 00-7.4 0L12 7l-1.4-1.4a5.2 5.2 0 10-7.4 7.4L12 21.8l8.8-8.8a5.2 5.2 0 000-7.4z"/></svg>
<span>Like</span>
</button>
</div>
<button type="button" class="btn btn-sm btn-outline-secondary rounded-pill px-3">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12v7a1 1 0 001 1h14a1 1 0 001-1v-3M16 6l-4-4-4 4M12 2v13"/></svg>
Share
</button>
</div>
<ul class="list-unstyled mb-0 px-4 pt-3 d-flex flex-column gap-3" id="sfComments" aria-live="polite">
<li class="d-flex gap-3">
<img src="https://i.pravatar.cc/80?img=47" alt="" width="36" height="36" class="rounded-circle flex-none">
<div class="sf-bubble rounded-4 px-3 py-2">
<div class="d-flex gap-2 align-items-baseline"><span class="fw-semibold small">Tina Domiaz</span><span class="small wdw-muted">1h</span></div>
<div class="small">Wow, what lens did you use for this one?</div>
</div>
</li>
<li class="d-flex gap-3">
<img src="https://i.pravatar.cc/80?img=15" alt="" width="36" height="36" class="rounded-circle flex-none">
<div class="sf-bubble rounded-4 px-3 py-2">
<div class="d-flex gap-2 align-items-baseline"><span class="fw-semibold small">Smith Helm</span><span class="small wdw-muted">45m</span></div>
<div class="small">The colours are unreal. Is this a long exposure?</div>
</div>
</li>
</ul>
<form class="d-flex align-items-center gap-3 p-4" id="sfForm" autocomplete="off">
<img src="https://i.pravatar.cc/80?img=12" alt="" width="36" height="36" class="rounded-circle flex-none">
<label for="sfInput" class="visually-hidden">Write a comment</label>
<input type="text" id="sfInput" class="form-control rounded-pill" placeholder="Add a comment">
<button type="submit" class="btn btn-primary rounded-pill px-3" aria-label="Post comment"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 2L11 13M22 2l-7 20-4-9-9-4z"/></svg><span class="d-none d-sm-inline">Post</span></button>
</form>
</article>
</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 */
.sf-round { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.sf-photo { aspect-ratio: 4 / 3; }
.sf-bubble { background: var(--bs-tertiary-bg); }
.flex-none { flex: none; }
.sf-stack img { border: 2px solid var(--bs-body-bg); }
.sf-stack img + img { margin-left: -8px; }
.btn-outline-secondary { --bs-btn-color: var(--bs-body-color); --bs-btn-border-color: var(--bs-border-color); }
#sfLike[aria-pressed="true"] { background: var(--bs-danger-bg-subtle); border-color: var(--bs-danger-border-subtle); color: var(--bs-danger-text-emphasis); }
#sfLike[aria-pressed="true"] svg { fill: currentColor; }
.sf-react { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 3; opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .15s, transform .15s, visibility .15s; }
.sf-like-wrap:hover .sf-react, .sf-like-wrap:focus-within .sf-react { opacity: 1; visibility: visible; transform: none; }
.sf-emoji { width: 40px; height: 40px; font-size: 1.25rem; line-height: 1; padding: 0; min-height: 40px; }
@media (prefers-reduced-motion: reduce) { .sf-react { transition: none; } }
(function () {
function initLike() {
var btn = document.getElementById('sfLike');
var out = document.getElementById('sfLikes');
if (!btn || !out) return;
function set(on) {
if ((btn.getAttribute('aria-pressed') === 'true') === on) return;
btn.setAttribute('aria-pressed', on);
out.textContent = parseInt(out.textContent, 10) + (on ? 1 : -1);
}
btn.addEventListener('click', function () { set(btn.getAttribute('aria-pressed') !== 'true'); });
document.querySelectorAll('[data-react]').forEach(function (r) {
r.addEventListener('click', function () { set(true); btn.focus(); });
});
}
function initComments() {
var form = document.getElementById('sfForm');
var input = document.getElementById('sfInput');
var list = document.getElementById('sfComments');
var count = document.getElementById('sfCount');
if (!form || !input || !list || !count) return;
form.addEventListener('submit', function (e) {
e.preventDefault();
var text = input.value.trim();
if (!text) return;
var li = document.createElement('li');
li.className = 'd-flex gap-3';
li.innerHTML = '<img src="https://i.pravatar.cc/80?img=12" alt="" width="36" height="36" class="rounded-circle flex-none">' +
'<div class="sf-bubble rounded-4 px-3 py-2"><div class="d-flex gap-2 align-items-baseline"><span class="fw-semibold small">You</span><span class="small wdw-muted">Just now</span></div><div class="small"></div></div>';
li.querySelector('.small:last-child').textContent = text;
list.appendChild(li);
count.textContent = parseInt(count.textContent, 10) + 1;
input.value = '';
});
}
initLike();
initComments();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.