32 CSS Floating Action Button Designs 08 / 32

Social Share FAB

Floating social share button cluster for X, Facebook, LinkedIn, WhatsApp, and copy link with animated reveal.

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

The code

<div class="fb08">
<div class="fb08-article">
  <div class="fb08-art-cover">
    <span class="fb08-art-tag">CSS Design</span>
  </div>

  <div class="fb08-art-body">
    <h2>Building a Floating Share Button Cluster — Pure CSS</h2>
    <p>A stacked share FAB that reveals Twitter/X, Facebook, LinkedIn, WhatsApp and copy-link buttons on click. Checkbox-hack driven with staggered spring transitions and branded icon buttons. Click the purple button →</p>
    <div class="fb08-art-meta">
      <strong>CodeFronts</strong>
      <span>5 min read</span>
      <span>2,400 shares</span>
    </div>
  </div>

  <!-- SHARE FAB -->
  <div class="fb08-share-root">
    <input type="checkbox" class="fb08-sh-check" id="fb08-sh1">

    <div class="fb08-sh-items">
      <!-- X / Twitter -->
      <div class="fb08-sh-item">
        <span class="fb08-sh-lbl">Share on X</span>
        <button class="fb08-sh-btn fb08-sh-btn--x" aria-label="Share on X">
          <svg viewBox="0 0 24 24"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.748l7.73-8.835L1.254 2.25H8.08l4.264 5.638 5.9-5.638zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
        </button>
      </div>
      <!-- Facebook -->
      <div class="fb08-sh-item">
        <span class="fb08-sh-lbl">Share on Facebook</span>
        <button class="fb08-sh-btn fb08-sh-btn--fb" aria-label="Share on Facebook">
          <svg viewBox="0 0 24 24"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>
        </button>
      </div>
      <!-- LinkedIn -->
      <div class="fb08-sh-item">
        <span class="fb08-sh-lbl">Share on LinkedIn</span>
        <button class="fb08-sh-btn fb08-sh-btn--li" aria-label="Share on LinkedIn">
          <svg viewBox="0 0 24 24"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>
        </button>
      </div>
      <!-- WhatsApp -->
      <div class="fb08-sh-item">
        <span class="fb08-sh-lbl">Share on WhatsApp</span>
        <button class="fb08-sh-btn fb08-sh-btn--wa" aria-label="Share on WhatsApp">
          <svg viewBox="0 0 24 24"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>
        </button>
      </div>
      <!-- Copy link -->
      <div class="fb08-sh-item">
        <span class="fb08-sh-lbl">Copy link</span>
        <button class="fb08-sh-btn fb08-sh-btn--link" aria-label="Copy link" id="fb08-copy-btn">
          <svg viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
        </button>
      </div>
    </div>

    <span class="fb08-sh-count">↑ Share</span>

    <label class="fb08-sh-trigger" for="fb08-sh1" aria-label="Share article">
      <svg viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11A3 3 0 0021 5a3 3 0 00-3-3 3 3 0 00-3 3c0 .24.04.47.09.7L8.04 9.81A3 3 0 005 9a3 3 0 00-3 3 3 3 0 003 3 3 3 0 003.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92S19.61 16.08 18 16.08z"/></svg>
    </label>
  </div>
</div>
</div>
.fb08, .fb08 *, .fb08 *::before, .fb08 *::after { box-sizing: border-box; margin: 0; padding: 0; }
.fb08 {
    font-family: 'DM Sans', sans-serif;
    background: #111827;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px;
    color: #f3f4f6;
  }

  /* article card mock */
  .fb08-article {
    width: min(660px, 100%);
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
  }

  .fb08-art-cover {
    height: 220px;
    background: linear-gradient(135deg, #1e3a5f, #2d6a9f, #3b82f6);
    display: flex;
    align-items: flex-end;
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
  }
  .fb08-art-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 60% at 30% 30%, rgba(255,255,255,.08), transparent);
  }
  .fb08-art-tag {
    background: rgba(59,130,246,.85);
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 5px 12px;
    border-radius: 6px;
    backdrop-filter: blur(8px);
    position: relative;
    z-index: 1;
  }

  .fb08-art-body {
    padding: 28px 28px 32px;
  }
  .fb08-art-body h2 {
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 12px;
    letter-spacing: -.01em;
  }
  .fb08-art-body p {
    color: #9ca3af;
    font-size: .9rem;
    line-height: 1.65;
    margin-bottom: 20px;
  }
  .fb08-art-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: .78rem;
    color: #6b7280;
  }
  .fb08-art-meta strong { color: #d1d5db; }
  .fb08-art-meta span::before { content: '·'; margin-right: 14px; }

  /* ── SHARE FAB cluster ── */
  .fb08-share-root {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 30;
  }

  /* hidden checkbox */
  .fb08-sh-check { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

  /* social items */
  .fb08-sh-items {
    position: absolute;
    bottom: 0;
    right: 0;
    pointer-events: none;
  }

  .fb08-sh-item {
    position: absolute;
    bottom: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity .25s ease, transform .3s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
  }

  .fb08-sh-lbl {
    font-size: .75rem;
    font-weight: 600;
    color: #f3f4f6;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(6px);
    transition: opacity .18s ease, transform .18s ease;
  }

  .fb08-sh-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.45);
    transition: transform .15s ease;
    flex-shrink: 0;
  }
  .fb08-sh-btn:hover { transform: scale(1.12); }
  .fb08-sh-btn:hover ~ .fb08-sh-lbl { opacity: 1; transform: none; }
  .fb08-sh-btn svg { width: 20px; height: 20px; fill: #fff; }

  /* brand colors */
  .fb08-sh-btn--x       { background: #000; }
  .fb08-sh-btn--fb      { background: #1877f2; }
  .fb08-sh-btn--li      { background: #0a66c2; }
  .fb08-sh-btn--wa      { background: #25d366; }
  .fb08-sh-btn--link    { background: #374151; }

  /* open state: stagger upward */
  .fb08-sh-check:checked ~ .fb08-sh-items { pointer-events: auto; }

  .fb08-sh-check:checked ~ .fb08-sh-items .fb08-sh-item:nth-child(1) {
    opacity: 1; pointer-events: auto;
    transform: translateY(-58px);
    transition-delay: 0s;
  }
  .fb08-sh-check:checked ~ .fb08-sh-items .fb08-sh-item:nth-child(2) {
    opacity: 1; pointer-events: auto;
    transform: translateY(-112px);
    transition-delay: .05s;
  }
  .fb08-sh-check:checked ~ .fb08-sh-items .fb08-sh-item:nth-child(3) {
    opacity: 1; pointer-events: auto;
    transform: translateY(-166px);
    transition-delay: .10s;
  }
  .fb08-sh-check:checked ~ .fb08-sh-items .fb08-sh-item:nth-child(4) {
    opacity: 1; pointer-events: auto;
    transform: translateY(-220px);
    transition-delay: .15s;
  }
  .fb08-sh-check:checked ~ .fb08-sh-items .fb08-sh-item:nth-child(5) {
    opacity: 1; pointer-events: auto;
    transform: translateY(-274px);
    transition-delay: .20s;
  }

  /* main share trigger */
  .fb08-sh-trigger {
    position: relative;
    z-index: 10;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    border: none;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 6px 22px rgba(99,102,241,.5), inset 0 1px 0 rgba(255,255,255,.18);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  }
  .fb08-sh-trigger:hover { transform: scale(1.08); box-shadow: 0 10px 30px rgba(99,102,241,.65), inset 0 1px 0 rgba(255,255,255,.2); }
  .fb08-sh-trigger svg { width: 22px; height: 22px; fill: #fff; transition: transform .28s cubic-bezier(.34,1.56,.64,1); }
  .fb08-sh-check:checked ~ .fb08-sh-trigger { transform: rotate(45deg); box-shadow: 0 8px 24px rgba(99,102,241,.5); }

  /* count bubble */
  .fb08-sh-count {
    position: absolute;
    top: 0;
    left: 0;
    background: #1f2937;
    border: 2px solid #374151;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: .72rem;
    font-weight: 700;
    color: #9ca3af;
    white-space: nowrap;
    transform: translateX(calc(-100% - 10px)) translateY(50%);
    bottom: auto;
    top: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease .25s;
  }
  .fb08-sh-check:checked ~ .fb08-sh-count { opacity: 1; }

  @media (prefers-reduced-motion: reduce) {
    .fb08-sh-item, .fb08-sh-trigger, .fb08-sh-btn { transition: none; }
  }
document.getElementById('fb08-copy-btn').addEventListener('click', () => {
    navigator.clipboard?.writeText(location.href).catch(()=>{});
    const btn = document.getElementById('fb08-copy-btn');
    btn.style.background = '#10b981';
    setTimeout(() => { btn.style.background = ''; }, 1500);
  });

Search CodeFronts

Loading…