Bootstrap 5 User Profile with Collapsible Sidebar
A profile layout with a collapsible sidebar holding the avatar, follow button and navigation, beside a timeline where new ideas can be posted.
<section class="wdw-stage">
<div class="container" style="max-width:1040px">
<div class="wdw-card overflow-hidden">
<div class="d-flex flex-column flex-lg-row" id="psWrap">
<div class="collapse collapse-horizontal show ps-collapse" id="psSide">
<aside class="ps-side border-bottom">
<div class="wdw-aurora ps-cover"></div>
<div class="text-center px-4 pb-4 ps-profile">
<img src="https://i.pravatar.cc/200?img=15" alt="Clark Rodriguez" width="88" height="88" class="rounded-circle mb-3 ps-ring">
<h1 class="h5 wdw-heading mb-1">Clark Rodriguez</h1>
<p class="small wdw-muted mb-3">Product designer</p>
<div class="d-flex justify-content-center gap-4 mb-3 small">
<div><div class="fw-bold">128</div><div class="wdw-muted">Posts</div></div>
<div><div class="fw-bold" id="psFollowers">2.4k</div><div class="wdw-muted">Followers</div></div>
</div>
<button type="button" class="btn btn-outline-primary btn-sm rounded-pill px-4" id="psFollow" aria-pressed="false">Follow</button>
</div>
<nav class="nav nav-pills flex-column gap-1 px-4 pb-4" aria-label="Profile">
<a class="nav-link rounded-pill active" href="#" aria-current="page">Overview</a>
<a class="nav-link rounded-pill" href="#">Account settings</a>
<a class="nav-link rounded-pill" href="#">Tasks</a>
<a class="nav-link rounded-pill" href="#">Help</a>
</nav>
</aside>
</div>
<main class="flex-grow-1 p-4 ps-min-w-0">
<div class="d-flex align-items-center justify-content-between mb-3">
<button type="button" class="btn btn-outline-primary btn-sm rounded-pill" id="psToggle" data-bs-toggle="collapse" data-bs-target="#psSide" aria-controls="psSide" aria-expanded="true">Hide menu</button>
<span class="wdw-eyebrow">Timeline</span>
</div>
<form class="d-flex gap-2 mb-4" id="psForm">
<label for="psIdea" class="visually-hidden">Write an idea</label>
<input type="text" class="form-control" id="psIdea" placeholder="Write an idea..." autocomplete="off">
<button type="submit" class="btn btn-primary rounded-pill px-4">Post</button>
</form>
<div class="list-group list-group-flush" id="psFeed">
<article class="list-group-item bg-transparent d-flex gap-3 px-0 py-3">
<img src="https://i.pravatar.cc/100?img=52" alt="" width="48" height="48" class="rounded-circle flex-shrink-0">
<div><div class="fw-semibold">Dan Hughes <span class="wdw-muted fw-normal small">· 2h</span></div><p class="mb-2">What if onboarding was a single screen? One input, one button, and the rest learned as people go.</p><div class="d-flex gap-2"><button type="button" class="btn btn-sm btn-light rounded-pill" data-like aria-pressed="false" data-count="12">Like · <span>12</span></button><button type="button" class="btn btn-sm btn-light rounded-pill">Reply</button></div></div>
</article>
<article class="list-group-item bg-transparent d-flex gap-3 px-0 py-3">
<img src="https://i.pravatar.cc/100?img=32" alt="" width="48" height="48" class="rounded-circle flex-shrink-0">
<div><div class="fw-semibold">Amy Cole <span class="wdw-muted fw-normal small">· 5h</span></div><p class="mb-2">Idea: let design tokens live in one JSON file so the whole team ships the same spacing and colour.</p><div class="d-flex gap-2"><button type="button" class="btn btn-sm btn-light rounded-pill" data-like aria-pressed="false" data-count="8">Like · <span>8</span></button><button type="button" class="btn btn-sm btn-light rounded-pill">Reply</button></div></div>
</article>
<article class="list-group-item bg-transparent d-flex gap-3 px-0 py-3">
<img src="https://i.pravatar.cc/100?img=47" alt="" width="48" height="48" class="rounded-circle flex-shrink-0">
<div><div class="fw-semibold">Rita Moon <span class="wdw-muted fw-normal small">· 1d</span></div><p class="mb-2">Empty states are free real estate. A short tip and one clear action beat a blank page every time.</p><div class="d-flex gap-2"><button type="button" class="btn btn-sm btn-light rounded-pill" data-like aria-pressed="false" data-count="21">Like · <span>21</span></button><button type="button" class="btn btn-sm btn-light rounded-pill">Reply</button></div></div>
</article>
</div>
</main>
</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 */
.ps-side { background: var(--bs-tertiary-bg); height: 100%; }
@media (min-width: 992px) { .ps-collapse.show, .ps-collapse.collapsing { width: 260px; } .ps-side { border-right: 1px solid var(--bs-border-color); border-bottom: 0 !important; } .ps-collapse > .ps-side { width: 260px; } }
.ps-cover { height: 80px; }
.ps-profile img { margin-top: -44px; position: relative; }
#psFeed .btn-light { --bs-btn-bg: var(--bs-tertiary-bg); --bs-btn-border-color: transparent; --bs-btn-color: var(--bs-body-color); --bs-btn-hover-bg: var(--bs-secondary-bg); --bs-btn-hover-color: var(--bs-body-color); --bs-btn-active-bg: var(--bs-primary-bg-subtle); --bs-btn-active-color: var(--bs-primary-text-emphasis); }
#psFeed .btn-light[aria-pressed="true"] { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.ps-min-w-0 { min-width: 0; }
.ps-ring { border: 4px solid var(--bs-body-bg); }
function initSidebarToggle() {
const btn = document.getElementById('psToggle');
const side = document.getElementById('psSide');
if (!btn || !side) return;
side.addEventListener('hidden.bs.collapse', () => { btn.textContent = 'Show menu'; btn.setAttribute('aria-expanded', 'false'); });
side.addEventListener('shown.bs.collapse', () => { btn.textContent = 'Hide menu'; btn.setAttribute('aria-expanded', 'true'); });
}
function initFollowBtn() {
const btn = document.getElementById('psFollow');
if (!btn) return;
btn.addEventListener('click', () => {
const on = btn.getAttribute('aria-pressed') !== 'true';
btn.setAttribute('aria-pressed', on);
btn.textContent = on ? 'Following' : 'Follow';
btn.classList.toggle('btn-outline-primary', !on);
btn.classList.toggle('btn-primary', on);
});
}
function initLikes() {
const feed = document.getElementById('psFeed');
if (!feed) return;
feed.addEventListener('click', (e) => {
const btn = e.target.closest('[data-like]');
if (!btn) return;
const on = btn.getAttribute('aria-pressed') !== 'true';
const count = parseInt(btn.dataset.count, 10) + (on ? 1 : 0);
btn.setAttribute('aria-pressed', on);
btn.querySelector('span').textContent = count;
btn.firstChild.textContent = on ? 'Liked · ' : 'Like · ';
});
}
function initPostIdea() {
const form = document.getElementById('psForm');
const feed = document.getElementById('psFeed');
if (!form || !feed) return;
form.addEventListener('submit', (e) => {
e.preventDefault();
const input = document.getElementById('psIdea');
const text = input.value.trim();
if (!text) return;
const item = document.createElement('article');
item.className = 'list-group-item bg-transparent d-flex gap-3 px-0 py-3';
const img = document.createElement('img');
img.src = 'https://i.pravatar.cc/100?img=15'; img.alt = ''; img.width = 48; img.height = 48; img.className = 'rounded-circle flex-shrink-0';
const body = document.createElement('div');
const name = document.createElement('div');
name.className = 'fw-semibold'; name.textContent = 'Clark Rodriguez · now';
const p = document.createElement('p');
p.className = 'mb-0'; p.textContent = text;
body.append(name, p);
item.append(img, body);
feed.prepend(item);
input.value = '';
});
}
initSidebarToggle();
initFollowBtn();
initLikes();
initPostIdea();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.