32 CSS Floating Action Button Designs 05 / 32

Floating Chat Widget

Floating chat widget FAB for WhatsApp and support chat with animated panel, notification badge, and smooth open/close transitions.

CSS + JS MIT licensed
Live Demo Open in tab
Open in playground

The code

<div class="fb05">
<div class="fb05-page-content">
  <h1>Floating Chat<br>Support Button</h1>
  <p>Click the green WhatsApp-style button in the bottom-right (or the indigo support button bottom-left) to open the live chat panel. Pure CSS panel animation, minimal JS for toggle state.</p>
  <span class="fb05-note">Bottom-right = WhatsApp · Bottom-left = Support chat</span>
</div>

<!-- WhatsApp-style float -->
<div class="fb05-chat-fab" id="fb05-chat-wa">
  <div class="fb05-chat-panel" id="fb05-panel-wa">
    <div class="fb05-cp-header">
      <div class="fb05-agent">
        <div class="fb05-cp-avatar">🧑</div>
        <div class="fb05-cp-info">
          <h3>Mia — Support</h3>
          <span>● Online now</span>
        </div>
      </div>
    </div>
    <div class="fb05-cp-body">
      <div class="fb05-cp-bubble">
        Hi there! 👋 How can I help you today?
      </div>
      <div class="fb05-cp-time">Just now</div>
    </div>
    <div class="fb05-cp-footer">
      <input class="fb05-cp-input" type="text" placeholder="Type a message…">
      <button class="fb05-cp-send" aria-label="Send">
        <svg viewBox="0 0 24 24"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>
      </button>
    </div>
  </div>

  <button class="fb05-chat-trigger" id="fb05-trig-wa" aria-label="Open chat" aria-expanded="false">
    <svg class="fb05-icon-chat" viewBox="0 0 24 24" width="32" height="32" fill="white">
      <path d="M20 2H4a2 2 0 00-2 2v18l4-4h14a2 2 0 002-2V4a2 2 0 00-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z"/>
    </svg>
    <svg class="fb05-icon-close" viewBox="0 0 24 24" width="28" height="28" fill="white">
      <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
    </svg>
    <span class="fb05-chat-badge">1</span>
  </button>
</div>

<!-- Support / indigo float -->
<div class="fb05-chat-fab fb05-chat-fab--indigo" id="fb05-chat-ind">
  <div class="fb05-chat-panel" id="fb05-panel-ind">
    <div class="fb05-cp-header" style="background: linear-gradient(135deg,#6366f1,#4338ca)">
      <div class="fb05-agent">
        <div class="fb05-cp-avatar">🤖</div>
        <div class="fb05-cp-info">
          <h3>AI Assistant</h3>
          <span>Replies instantly</span>
        </div>
      </div>
    </div>
    <div class="fb05-cp-body" style="background:#f0f0ff">
      <div class="fb05-cp-bubble">
        Hello! Ask me anything about our products.
      </div>
      <div class="fb05-cp-time">Just now</div>
    </div>
    <div class="fb05-cp-footer">
      <input class="fb05-cp-input" type="text" placeholder="Ask a question…">
      <button class="fb05-cp-send" aria-label="Send" style="background:#6366f1">
        <svg viewBox="0 0 24 24"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>
      </button>
    </div>
  </div>
  <button class="fb05-chat-trigger fb05-chat-trigger--ind" id="fb05-trig-ind" aria-label="Open AI chat" aria-expanded="false">
    <svg class="fb05-icon-chat" viewBox="0 0 24 24" width="30" height="30" fill="white">
      <path d="M12 3C6.48 3 2 6.92 2 11.7c0 2.65 1.35 5.02 3.5 6.67V21l3.08-1.7A11 11 0 0012 19.4c5.52 0 10-3.92 10-8.7S17.52 3 12 3zm1 11.5h-2v-2h2v2zm0-4h-2V6.5h2V10.5z"/>
    </svg>
    <svg class="fb05-icon-close" viewBox="0 0 24 24" width="28" height="28" fill="white">
      <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
    </svg>
  </button>
</div>
</div>
.fb05, .fb05 *, .fb05 *::before, .fb05 *::after { box-sizing: border-box; margin: 0; padding: 0; }
.fb05 {
    font-family: 'Inter', sans-serif;
    background: #f4f4f0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px;
    color: #1a1a1a;
  }

  .fb05-page-content {
    text-align: center;
    max-width: 560px;
    padding: 60px 24px;
  }
  .fb05-page-content h1 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.15;
    margin-bottom: 16px;
  }
  .fb05-page-content p {
    color: #64748b;
    line-height: 1.65;
    font-size: .95rem;
  }
  .fb05-page-content .fb05-note {
    display: inline-block;
    margin-top: 24px;
    font-size: .78rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
  }

  /* ══════════════════════════════
     FLOATING CHAT WIDGET — VARIANT 1: WhatsApp green
  ══════════════════════════════ */
  .fb05-chat-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
  }

  /* chat panel */
  .fb05-chat-panel {
    background: #fff;
    border-radius: 18px;
    width: 300px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
    opacity: 0;
    transform: translateY(12px) scale(.96);
    pointer-events: none;
    transform-origin: bottom right;
    transition: opacity .28s ease, transform .32s cubic-bezier(.34,1.56,.64,1);
  }
  .fb05-chat-panel.fb05-open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .fb05-cp-header {
    background: linear-gradient(135deg, #25d366, #128c7e);
    padding: 18px 18px 24px;
    color: #fff;
    position: relative;
  }
  .fb05-cp-header .fb05-agent {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .fb05-cp-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: grid;
    place-items: center;
    font-size: 22px;
    flex-shrink: 0;
    position: relative;
  }
  .fb05-cp-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #7fe87f;
    border: 2px solid #128c7e;
  }
  .fb05-cp-info h3 { font-size: .96rem; font-weight: 600; }
  .fb05-cp-info span { font-size: .76rem; opacity: .8; }

  .fb05-cp-body {
    padding: 18px;
    background: #ecfdf5;
    min-height: 100px;
  }
  .fb05-cp-bubble {
    background: #fff;
    border-radius: 0 12px 12px 12px;
    padding: 10px 14px;
    font-size: .85rem;
    line-height: 1.5;
    color: #1a1a1a;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    max-width: 90%;
    position: relative;
  }
  .fb05-cp-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -7px;
    border: 7px solid transparent;
    border-top-color: #fff;
    border-right-color: #fff;
  }
  .fb05-cp-time {
    text-align: right;
    font-size: .67rem;
    color: #94a3b8;
    margin-top: 4px;
  }

  .fb05-cp-footer {
    padding: 14px 18px;
    display: flex;
    gap: 8px;
    border-top: 1px solid #f0f0f0;
  }
  .fb05-cp-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: .85rem;
    font-family: inherit;
    outline: none;
    background: #f8fafc;
  }
  .fb05-cp-input:focus { border-color: #25d366; }
  .fb05-cp-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #25d366;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: transform .15s ease, background .15s;
  }
  .fb05-cp-send:hover { background: #22c55e; transform: scale(1.08); }
  .fb05-cp-send svg { width: 17px; height: 17px; fill: #fff; }

  /* trigger button */
  .fb05-chat-trigger {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #25d366, #128c7e);
    box-shadow: 0 6px 24px rgba(37,211,102,.45), inset 0 1px 0 rgba(255,255,255,.2);
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease;
    position: relative;
  }
  .fb05-chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 32px rgba(37,211,102,.6), inset 0 1px 0 rgba(255,255,255,.2);
  }
  .fb05-chat-trigger svg { width: 32px; height: 32px; fill: #fff; }

  /* pulsing ring */
  .fb05-chat-trigger::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(37,211,102,.5);
    animation: fb05-pulse-ring 2.2s ease-out infinite;
  }
  @keyframes fb05-pulse-ring {
    0% { transform: scale(.9); opacity: .7; }
    70% { transform: scale(1.18); opacity: 0; }
    100% { transform: scale(1.18); opacity: 0; }
  }

  /* notification badge */
  .fb05-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    border: 2px solid #f4f4f0;
    animation: fb05-badge-pop .4s cubic-bezier(.34,1.56,.64,1) both;
  }
  @keyframes fb05-badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
  }

  /* icon morph: chat → X */
  .fb05-chat-trigger .fb05-icon-chat { transition: opacity .2s, transform .2s; }
  .fb05-chat-trigger .fb05-icon-close { position: absolute; opacity: 0; transition: opacity .2s, transform .2s; transform: rotate(-45deg); }
  .fb05-chat-trigger.fb05-open .fb05-icon-chat { opacity: 0; transform: rotate(45deg); }
  .fb05-chat-trigger.fb05-open .fb05-icon-close { opacity: 1; transform: rotate(0deg); }

  /* ══ VARIANT 2: Indigo support ══ */
  .fb05-chat-fab--indigo {
    bottom: 32px;
    left: 32px;
    right: auto;
  }
  .fb05-chat-trigger--ind {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 6px 24px rgba(99,102,241,.4), inset 0 1px 0 rgba(255,255,255,.2);
  }
  .fb05-chat-trigger--ind::before { border-color: rgba(99,102,241,.45); }
  .fb05-chat-trigger--ind:hover { box-shadow: 0 10px 32px rgba(99,102,241,.55), inset 0 1px 0 rgba(255,255,255,.2); }

  @media (prefers-reduced-motion: reduce) {
    .fb05-chat-trigger::before { animation: none; }
    .fb05-chat-panel, .fb05-chat-trigger { transition: none; }
  }
  @media (max-width: 480px) {
    .fb05-chat-panel { width: calc(100vw - 64px); }
    .fb05-chat-fab--indigo { display: none; }
  }
function setupChat(triggerId, panelId) {
    const trig = document.getElementById(triggerId);
    const panel = document.getElementById(panelId);
    let open = false;

    trig.addEventListener('click', () => {
      open = !open;
      trig.classList.toggle('fb05-open', open);
      panel.classList.toggle('fb05-open', open);
      trig.setAttribute('aria-expanded', open);
      // hide badge on first open
      const badge = trig.querySelector('.fb05-chat-badge');
      if (badge && open) badge.style.display = 'none';
    });
  }

  setupChat('fb05-trig-wa', 'fb05-panel-wa');
  setupChat('fb05-trig-ind', 'fb05-panel-ind');

Search CodeFronts

Loading…