Back to buttons

Live preview

Preview settings

Changes appear as you type. Use Tab to test keyboard focus.

⌘ / Ctrl + S saves locally

Beer Like Button

HTML, CSS or Tailwind, and a little JavaScript. One button or a group of up to six.

By @shraddha761

Remix button

Button submission checks

Checks will appear after the preview updates.

Buttons only: no full pages, forms, cards or navigation. Put scripts in the JavaScript tab. Tailwind uses utilities from HTML and JavaScript; use complete class names. Custom CSS supports plain CSS, without @apply, imports or plugins.

Accessibility quick check

Waiting for the rendered preview…

Try Tab, Enter and Space in the preview. Check the focus ring, hover and disabled states, then enable Reduce motion. These checks are guidance, not an accessibility certification.

Explore freely here. Remix to publish your version with credit to the creator.

About Beer Like Button

Beer Like Button is an animated CSS button by @shraddha761. Preview the interaction, customize its HTML, styles and JavaScript, or download the files with creator credit.

Effects and categories
Hover effects, Icon, Social, 3D, Animated
Using this example
Copy the HTML or download index.html, style.css and app.js. Test keyboard focus, motion and contrast in your own project.

Usage, Tailwind and licensing questions

Read the source files

HTML

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title> Beer Like Button</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/inter-ui@3.11.0/inter.min.css'><link rel="stylesheet" href="./style.css">

</head>
<body>
<!-- partial:index.partial.html -->
<button class="beer-like" data-count="42">
    <svg class="right">
        <use xlink:href="#beer">
    </svg>
    <svg class="left">
        <use xlink:href="#beer">
    </svg>
</button>
        
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
    <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 38" id="beer">
        <path d="M27.3442657,10.9323999 L27.3442657,30.4083463 C27.3442657,30.6656011 27.3885964,30.9208753 27.475256,31.1626416 L28.4584173,33.9055044 C28.8690541,35.0511154 28.286502,36.317526 27.1572509,36.7341117 C26.9189371,36.8220268 26.6673082,36.8669997 26.4137272,36.8669997 L8.6936804,36.8669997 C7.49208526,36.8669997 6.51799995,35.8788026 6.51799995,34.6597997 C6.51799995,34.402545 6.56233068,34.1472707 6.64899021,33.9055044 L7.63215163,31.1626416 C7.71881116,30.9208753 7.76314189,30.6656011 7.76314189,30.4083463 L7.76314189,10.9323999"></path>
        <path d="M7.37976466,10.7050955 C4.03739944,7.21236807 7.37976466,4.43127908 9.62402739,4.68029805 C10.9707312,-0.311641291 16.3416716,-0.14115035 17.4789469,4.68029805 C19.1709488,-0.486993238 25.0730464,0.289582317 25.3338664,5.22597205 C29.5557705,3.93166238 30.2108846,9.27699993 27.5781291,10.7050955 L17.4789469,10.7050955 C17.8529907,15.2710317 16.7308593,17.5539999 14.1125529,17.5539999 C11.4942463,17.5539999 10.5591369,15.2710317 11.3072244,10.7050955 L7.37976466,10.7050955 Z"></path>
        <path d="M7.62159994,12.5877999 C-4.64593547,12.5877999 3.03123906,24.2813068 7.62159994,28.5899998 L7.62159994,23.890911 C3.60560163,21.0340593 1.29269476,15.5984013 7.62159994,15.5984013 L7.62159994,12.5877999 Z"></path>
        <line x1="12.3051233" y1="20.3129998" x2="12.3186765" y2="29.1054606"></line>
        <line x1="17.8231233" y1="20.3129998" x2="17.8366765" y2="29.1054606"></line>
        <line x1="23.3411232" y1="16.4503999" x2="23.3546764" y2="29.1054606"></line>
    </symbol>
</svg>
        
<!-- partial -->
  <script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/3.1.1/gsap.min.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/Physics2DPlugin3.min.js'></script><script  src="./app.js"></script>

</body>
</html>

CSS


.beer-like {
    --primary: #6D58FF;
    --secondary: #362A89;
    --border: #D1D6EE;
    --background: #fff;
    --shadow: rgba(0, 13, 88, 0.1);
    --shadow-light: rgba(0, 13, 88, 0.05);
    --color-add: #fff;
    --color-count: #646B8C;
    position: relative;
    outline: none;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--background);
    box-shadow: 0 1px var(--blur, 4px) var(--shadow-light), 0 2px calc(var(--blur, 4px) * 2) var(--shadow);
    cursor: pointer;
    padding: 0;
    
    -webkit-tap-highlight-color: transparent;
    transition: box-shadow 0.3s;
  }
  .beer-like:hover {
    --blur: 7px;
  }
  .beer-like:active {
    --blur: 3px;
  }
  .beer-like:before, .beer-like:after {
    content: var(--content, attr(data-count));
    display: block;
    position: absolute;
    right: 110%;
    top: 50%;
    font-family: inherit;
    text-align: center;
    font-weight: var(--fw, 500);
    color: var(--c, var(--color-count));
    font-size: var(--fs, 14px);
    width: 32px;
    height: 32px;
    line-height: 32px;
    margin: -16px 0 0 0;
  }
  .beer-like:after {
    --content: "+1";
    --fw: bold;
    --fs: 12px;
    --c: var(--color-add);
    border-radius: 50%;
    background: var(--primary);
    opacity: 0;
    transform: scale(0.5);
  }
  .beer-like .dot-primary,
  .beer-like .dot-secondary {
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--inner, var(--primary));
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 4px;
  }
  .beer-like .dot-secondary {
    --inner: var(--secondary);
  }
  .beer-like svg {
    width: 30px;
    height: 38px;
    display: block;
    fill: #fff;
    z-index: 1;
    stroke: var(--stroke, var(--primary));
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    position: absolute;
    left: 35px;
    top: 31px;
    transform: scaleX(var(--scale-x, 1)) rotate(10deg) translate(var(--x, -11px), var(--y, 4px)) translateZ(0);
  }
  .beer-like svg.right {
    --stroke: var(--secondary);
    --scale-x: -1;
    --y: -4px;
  }
  .beer-like.cheer:after {
    -webkit-animation: count 1s ease;
            animation: count 1s ease;
  }
  .beer-like.cheer svg {
    -webkit-animation: cheer 1s ease;
            animation: cheer 1s ease;
  }
  
  @-webkit-keyframes count {
    15% {
      opacity: 1;
      transform: scale(1.15) translateZ(0);
    }
    25% {
      transform: scale(0.95) translateZ(0);
    }
    50% {
      transform: scale(1) translateZ(0);
    }
    60% {
      opacity: 1;
    }
    100% {
      transform: translateY(-60px) translateZ(0);
    }
  }
  
  @keyframes count {
    15% {
      opacity: 1;
      transform: scale(1.15) translateZ(0);
    }
    25% {
      transform: scale(0.95) translateZ(0);
    }
    50% {
      transform: scale(1) translateZ(0);
    }
    60% {
      opacity: 1;
    }
    100% {
      transform: translateY(-60px) translateZ(0);
    }
  }
  @-webkit-keyframes cheer {
    35% {
      transform: scaleX(var(--scale-x, 1)) rotate(16deg) translate(-18px, var(--y, 4px)) translateZ(0);
    }
    55% {
      transform: scaleX(var(--scale-x, 1)) rotate(6deg) translate(-9px, var(--y, 4px)) translateZ(0);
    }
  }
  @keyframes cheer {
    35% {
      transform: scaleX(var(--scale-x, 1)) rotate(16deg) translate(-18px, var(--y, 4px)) translateZ(0);
    }
    55% {
      transform: scaleX(var(--scale-x, 1)) rotate(6deg) translate(-9px, var(--y, 4px)) translateZ(0);
    }
  }
  html {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
  }
  
  * {
    box-sizing: inherit;
  }
  *:before, *:after {
    box-sizing: inherit;
  }
  
  body {
    min-height: 100vh;
    display: flex;
    font-family: "Inter UI", "Inter", Arial;
    justify-content: center;
    align-items: center;
    background: #FBFCFF;
  }
  body .dribbble {
    position: fixed;
    display: block;
    right: 20px;
    bottom: 20px;
  }
  body .dribbble img {
    display: block;
    height: 28px;
  }
  body .twitter {
    position: fixed;
    display: block;
    right: 64px;
    bottom: 14px;
  }
  body .twitter svg {
    width: 32px;
    height: 32px;
    fill: #1da1f2;
  }

JavaScript

gsap.registerPlugin(Physics2DPlugin);

document.querySelectorAll('.beer-like').forEach(button => {

    button.addEventListener('click', e => {
        if(!button.classList.contains('cheer')) {

            button.classList.add('cheer');

            setTimeout(() => {
                particles(button, 12, 44, 38, -110, -80)
                button.dataset.count = parseInt(button.dataset.count) + 1;
            }, 500);

            setTimeout(() => button.classList.remove('cheer'), 1000);

        }
    });

});

function particles(parent, quantity, x, y, minAngle, maxAngle) {
    let minSize = 20,
        maxSize = 60;
    for(let i = quantity - 1; i >= 0; i--) {
        let angle = minAngle + Math.random() * (maxAngle - minAngle),
            size = minSize + Math.random() * (maxSize - minSize),
            velocity = 70 + Math.random() * (120 - 80),
            dot = document.createElement('div');
        dot.className = Math.random() >= .5 ? 'dot-primary' : 'dot-secondary';
        parent.appendChild(dot);
        gsap.set(dot, {
            opacity: 1,
            x: x,
            y: y,
            scale: size / 40
        });
        gsap.timeline({
            onComplete() {
                dot.remove();
            }
        }).to(dot, 1.8, {
            physics2D: {
                angle: angle,
                velocity: velocity,
                gravity: 125
            }
        }).to(dot, 1, {
            opacity: 0
        }, .8);
    }
}