Snippets Chat

Bootstrap 5 Message Inbox with Chat Layout

A two-pane messaging layout with a filterable, searchable conversation list and a chat view where you can send messages and get replies.

Bootstrap 5 No jQuery Oct 2020 2.1K views

<section class="wdw-stage">
  <div class="container" style="max-width:1100px">
    <div class="wdw-card overflow-hidden mail" id="mail">
      <div class="row g-0 mail-grid">
        <aside class="col-md-5 col-lg-4 border-end mail-list d-flex flex-column" aria-label="Conversations">
          <div class="p-3 pb-2 d-flex align-items-center justify-content-between">
            <h1 class="h5 fw-bold mb-0">Messages</h1>
            <button class="btn btn-primary btn-sm rounded-pill px-3" type="button">New</button>
          </div>
          <ul class="nav nav-pills px-3 gap-1 mb-2 flex-nowrap overflow-auto" id="mailTabs">
            <li class="nav-item"><button class="nav-link active py-1 px-3 rounded-pill d-flex align-items-center gap-1" data-filter="all" type="button" aria-pressed="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 12h-6l-2 3h-4l-2-3H2"/><path d="M5.5 5.1 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.5-6.9A2 2 0 0 0 16.7 4H7.2a2 2 0 0 0-1.7 1.1Z"/></svg>Inbox <span class="badge text-bg-primary-subtle ms-1">4</span></button></li>
            <li class="nav-item"><button class="nav-link py-1 px-3 rounded-pill d-flex align-items-center gap-1" data-filter="starred" type="button" aria-pressed="false"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m12 2 3.1 6.3 6.9 1-5 4.9 1.2 6.8L12 17.8 5.8 21l1.2-6.8-5-4.9 6.9-1Z"/></svg>Starred <span class="badge text-bg-primary-subtle ms-1">2</span></button></li>
            <li class="nav-item"><button class="nav-link py-1 px-3 rounded-pill d-flex align-items-center gap-1" data-filter="sent" type="button" aria-pressed="false"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 2 11 13M22 2l-7 20-4-9-9-4 20-7Z"/></svg>Sent <span class="badge text-bg-primary-subtle ms-1">2</span></button></li>
          </ul>
          <div class="px-3 pb-2">
            <label class="visually-hidden" for="mailSearch">Search messages</label>
            <input id="mailSearch" type="search" class="form-control form-control-sm rounded-pill bg-body-tertiary border-0 px-3" placeholder="Search messages">
          </div>
          <div class="list-group list-group-flush overflow-auto flex-grow-1" id="mailItems">
            <button class="list-group-item list-group-item-action active-thread d-flex gap-3 border-0" type="button" data-thread="0" data-tags="all" aria-current="true">
              <img src="https://i.pravatar.cc/80?img=12" class="rounded-circle" width="44" height="44" alt=""><span class="flex-grow-1 text-start min-w-0"><span class="d-flex justify-content-between"><strong class="small">Elon Musk</strong><span class="small wdw-muted">2:32 PM</span></span><span class="small wdw-muted d-block text-truncate">I've seen your new template, it's amazing!</span></span><span class="badge rounded-pill text-bg-primary align-self-center" data-unread>1<span class="visually-hidden"> unread message</span></span>
            </button>
            <button class="list-group-item list-group-item-action d-flex gap-3 border-0" type="button" data-thread="1" data-tags="all starred">
              <img src="https://i.pravatar.cc/80?img=32" class="rounded-circle" width="44" height="44" alt=""><span class="flex-grow-1 text-start min-w-0"><span class="d-flex justify-content-between"><strong class="small">Sara Chen</strong><span class="small wdw-muted">3:56 PM</span></span><span class="small wdw-muted d-block text-truncate">Of course, just call me before that.</span></span>
            </button>
            <button class="list-group-item list-group-item-action d-flex gap-3 border-0" type="button" data-thread="2" data-tags="all sent">
              <img src="https://i.pravatar.cc/80?img=47" class="rounded-circle" width="44" height="44" alt=""><span class="flex-grow-1 text-start min-w-0"><span class="d-flex justify-content-between"><strong class="small">Maya Ortiz</strong><span class="small wdw-muted">5:21 PM</span></span><span class="small wdw-muted d-block text-truncate">Hey, you asked for my feedback. It's brilliant.</span></span><span class="badge rounded-pill text-bg-primary align-self-center" data-unread>1<span class="visually-hidden"> unread message</span></span>
            </button>
            <button class="list-group-item list-group-item-action d-flex gap-3 border-0" type="button" data-thread="3" data-tags="all starred sent">
              <img src="https://i.pravatar.cc/80?img=5" class="rounded-circle" width="44" height="44" alt=""><span class="flex-grow-1 text-start min-w-0"><span class="d-flex justify-content-between"><strong class="small">Priya Nair</strong><span class="small wdw-muted">6:13 PM</span></span><span class="small wdw-muted d-block text-truncate">And invite Daniel too, please.</span></span>
            </button>
          </div>
        </aside>
        <div class="col-md-7 col-lg-8 d-flex flex-column mail-chat bg-body-tertiary">
          <header class="d-flex align-items-center gap-3 p-3 bg-body border-bottom shadow-sm position-relative">
            <button class="btn btn-sm btn-outline-secondary rounded-circle p-0 d-md-none flex-shrink-0" style="width:44px;height:44px" type="button" id="mailBack" aria-label="Back to conversations"><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="m15 18-6-6 6-6"/></svg></button>
            <img id="chatAvatar" src="https://i.pravatar.cc/80?img=12" class="rounded-circle" width="40" height="40" alt="">
            <div><div class="fw-bold" id="chatName">Elon Musk</div><div class="small text-success">Online</div></div>
          </header>
          <div class="flex-grow-1 p-3 p-md-4 d-flex flex-column gap-3 overflow-auto" id="chatLog" role="log" aria-live="polite" aria-label="Conversation"></div>
          <form class="p-3 bg-body border-top d-flex gap-2" id="chatForm">
            <label class="visually-hidden" for="chatInput">Message</label>
            <input id="chatInput" class="form-control rounded-pill px-4" placeholder="Write a message" autocomplete="off">
            <button class="btn btn-primary rounded-circle p-0 flex-shrink-0" style="width:44px" type="submit" aria-label="Send"><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 2 11 13M22 2l-7 20-4-9-9-4 20-7Z"/></svg></button>
          </form>
        </div>
      </div>
    </div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.