Snippets Chat

Bootstrap 5 Chat Box Template with Contact List

A two-pane messaging layout with a searchable contact list, presence dots and a conversation view with bubbles and a composer. On small screens it switches to a list-then-thread flow.

Bootstrap 5 No jQuery Sep 2019 8.4K views

<section class="wdw-stage">
  <div class="container" style="max-width: 980px">
    <div class="wdw-card chat show-list overflow-hidden">
      <aside class="chat-list" aria-label="Conversations">
        <div class="p-3 pb-2">
          <h1 class="h5 wdw-heading mb-3">Messages</h1>
          <label class="visually-hidden" for="chatSearch">Search conversations</label>
          <input type="search" id="chatSearch" class="form-control rounded-pill bg-body-tertiary border-0" placeholder="Search people">
        </div>
        <ul class="list-group list-group-flush list-unstyled m-0 px-2 pb-2 overflow-auto" id="contacts">
          <li><button type="button" class="list-group-item list-group-item-action contact d-flex align-items-center gap-3 border-0 rounded-3 py-2 active-contact" data-name="Maryam Naz" data-img="47" data-status="Online" aria-current="true">
            <span class="position-relative flex-none"><img src="https://i.pravatar.cc/80?img=47" alt="" width="44" height="44" class="rounded-circle"><span class="position-absolute bottom-0 end-0 p-1 rounded-circle border border-2 border-body bg-success"></span></span>
            <span class="flex-grow-1 text-start text-truncate"><strong class="d-block">Maryam Naz</strong><small class="text-body-secondary">Looking for your next template</small></span>
            <span class="d-flex flex-column align-items-end gap-1"><small class="text-body-secondary">9:05</small><span class="badge rounded-pill text-bg-primary">2</span></span></button></li>
          <li><button type="button" class="list-group-item list-group-item-action contact d-flex align-items-center gap-3 border-0 rounded-3 py-2" data-name="Sahar Darya" data-img="32" data-status="Away">
            <span class="position-relative flex-none"><img src="https://i.pravatar.cc/80?img=32" alt="" width="44" height="44" class="rounded-circle"><span class="position-absolute bottom-0 end-0 p-1 rounded-circle border border-2 border-body bg-secondary"></span></span>
            <span class="flex-grow-1 text-start text-truncate"><strong class="d-block">Sahar Darya</strong><small class="text-body-secondary">Sounds good, see you then</small></span>
            <span class="d-flex flex-column align-items-end gap-1"><small class="text-body-secondary">8:12</small></span></button></li>
          <li><button type="button" class="list-group-item list-group-item-action contact d-flex align-items-center gap-3 border-0 rounded-3 py-2" data-name="Yolduz Rafi" data-img="45" data-status="Online">
            <span class="position-relative flex-none"><img src="https://i.pravatar.cc/80?img=45" alt="" width="44" height="44" class="rounded-circle"><span class="position-absolute bottom-0 end-0 p-1 rounded-circle border border-2 border-body bg-success"></span></span>
            <span class="flex-grow-1 text-start text-truncate"><strong class="d-block">Yolduz Rafi</strong><small class="text-body-secondary">Sent the design files</small></span>
            <span class="d-flex flex-column align-items-end gap-1"><small class="text-body-secondary">Mon</small><span class="badge rounded-pill text-bg-primary">1</span></span></button></li>
          <li><button type="button" class="list-group-item list-group-item-action contact d-flex align-items-center gap-3 border-0 rounded-3 py-2" data-name="Nargis Hawa" data-img="44" data-status="Away">
            <span class="position-relative flex-none"><img src="https://i.pravatar.cc/80?img=44" alt="" width="44" height="44" class="rounded-circle"><span class="position-absolute bottom-0 end-0 p-1 rounded-circle border border-2 border-body bg-secondary"></span></span>
            <span class="flex-grow-1 text-start text-truncate"><strong class="d-block">Nargis Hawa</strong><small class="text-body-secondary">Thanks for the update!</small></span>
            <span class="d-flex flex-column align-items-end gap-1"><small class="text-body-secondary">Sun</small></span></button></li>
          <li><button type="button" class="list-group-item list-group-item-action contact d-flex align-items-center gap-3 border-0 rounded-3 py-2" data-name="Omid Karim" data-img="15" data-status="Online">
            <span class="position-relative flex-none"><img src="https://i.pravatar.cc/80?img=15" alt="" width="44" height="44" class="rounded-circle"><span class="position-absolute bottom-0 end-0 p-1 rounded-circle border border-2 border-body bg-success"></span></span>
            <span class="flex-grow-1 text-start text-truncate"><strong class="d-block">Omid Karim</strong><small class="text-body-secondary">Can we move the call to 3?</small></span>
            <span class="d-flex flex-column align-items-end gap-1"><small class="text-body-secondary">Sat</small></span></button></li>
          <li><button type="button" class="list-group-item list-group-item-action contact d-flex align-items-center gap-3 border-0 rounded-3 py-2" data-name="Laila Noor" data-img="25" data-status="Away">
            <span class="position-relative flex-none"><img src="https://i.pravatar.cc/80?img=25" alt="" width="44" height="44" class="rounded-circle"><span class="position-absolute bottom-0 end-0 p-1 rounded-circle border border-2 border-body bg-secondary"></span></span>
            <span class="flex-grow-1 text-start text-truncate"><strong class="d-block">Laila Noor</strong><small class="text-body-secondary">Invoice paid, thank you</small></span>
            <span class="d-flex flex-column align-items-end gap-1"><small class="text-body-secondary">Fri</small></span></button></li>
        </ul>
      </aside>

      <section class="chat-main d-flex flex-column" aria-label="Conversation">
        <header class="d-flex align-items-center gap-3 px-3 py-3 border-bottom">
          <button type="button" class="btn btn-icon btn-outline-secondary border-0 bg-body-tertiary text-body rounded-circle d-md-none back" aria-label="Back to conversations"><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="m15 18-6-6 6-6"/></svg></button>
          <span class="position-relative flex-none"><img id="peerImg" src="https://i.pravatar.cc/80?img=47" alt="" width="44" height="44" class="rounded-circle"><span id="peerDot" class="position-absolute bottom-0 end-0 p-1 rounded-circle border border-2 border-body bg-success"></span></span>
          <div class="flex-grow-1 lh-sm"><strong id="peerName" class="d-block">Maryam Naz</strong><small id="peerStatus" class="text-success-emphasis">Online</small></div>
          <button type="button" class="btn btn-icon btn-outline-secondary border-0 bg-body-tertiary text-body rounded-circle" aria-label="Call"><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="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.500 19.500 0 0 1-6-6A19.800 19.800 0 0 1 2.100 4.200 2 2 0 0 1 4.100 2h3a2 2 0 0 1 2 1.700c.1 1 .4 1.900.7 2.800a2 2 0 0 1-.5 2.100L8.100 9.900a16 16 0 0 0 6 6l1.300-1.300a2 2 0 0 1 2.100-.4c.9.300 1.800.6 2.800.7a2 2 0 0 1 1.700 2z"/></svg></button>
        </header>

        <div class="msgs flex-grow-1 overflow-auto p-3 d-flex flex-column gap-2 bg-body-tertiary" id="msgs" tabindex="0" aria-live="polite">
          <div class="text-center"><span class="badge rounded-pill bg-body text-body-secondary border fw-medium">Today</span></div>
          <div class="msg in"><p>Hi, how are you Samim?</p><small>8:40 AM</small></div>
          <div class="msg out"><p>Hi Maryam, I am good thanks. How about you?</p><small>8:55 AM</small></div>
          <div class="msg in"><p>I am good too, thank you for your chat template.</p><small>9:00 AM</small></div>
          <div class="msg out"><p>You are welcome!</p><small>9:05 AM</small></div>
          <div class="msg in"><p>I am looking for your next templates too.</p><small>9:06 AM</small></div>
          <div class="msg in typing" id="typing"><p aria-label="Maryam is typing"><i></i><i></i><i></i></p></div>
        </div>

        <form class="d-flex align-items-center gap-2 p-3 border-top" id="chatForm">
          <label class="visually-hidden" for="chatInput">Message</label>
          <input id="chatInput" class="form-control rounded-pill" placeholder="Type your message" autocomplete="off">
          <button class="btn btn-primary btn-icon rounded-circle flex-none" 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-4z"/></svg></button>
        </form>
      </section>
    </div>
  </div>
</section>

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

Free to use in personal and commercial projects under the MIT license.