AI CSS Animations

Emoji Reaction Bar Hover

Hover the Like button and a bar of six reactions pops up above it, each emoji springing in a few milliseconds after the last. Hovering an emoji lifts and enlarges it.

Also known as: facebook reactions css, reaction picker on hover, emoji popup on hover.

HTML

<div class="hfx-emoji-reactions">
  <button class="hfx-emoji-reactions-like"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 10v10H4.5A1.5 1.5 0 0 1 3 18.5v-7A1.5 1.5 0 0 1 4.5 10zM7 10l4-7a2.5 2.5 0 0 1 2.5 2.5V9h5a2 2 0 0 1 2 2.3l-1.3 7A2 2 0 0 1 17.2 20H7"/></svg> Like</button>
  <div class="hfx-emoji-reactions-bar" role="group" aria-label="Reactions">
    <button aria-label="Like" style="--i: 0">&#128077;</button>
    <button aria-label="Love" style="--i: 1">&#10084;&#65039;</button>
    <button aria-label="Haha" style="--i: 2">&#128514;</button>
    <button aria-label="Wow" style="--i: 3">&#128558;</button>
    <button aria-label="Sad" style="--i: 4">&#128546;</button>
    <button aria-label="Angry" style="--i: 5">&#128545;</button>
  </div>
</div>

CSS

.hfx-emoji-reactions {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  display: inline-block;
  margin-top: 3.3em; /* room for the bar in this preview */
  font-family: system-ui, sans-serif;
}
.hfx-emoji-reactions-like {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.55em 1.05em;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  border-radius: 99em;
  background: color-mix(in srgb, var(--c) 8%, transparent);
  color: var(--c);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.hfx-emoji-reactions-like svg { width: 1.1em; height: 1.1em; }
.hfx-emoji-reactions-bar {
  position: absolute;
  bottom: calc(100% + 0.5em);
  left: 50%;
  display: flex;
  gap: 0.1em;
  padding: 0.3em;
  border-radius: 99em;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 0.6em 1.4em -0.5em rgba(15, 23, 42, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(0.5em) scale(0.85);
  transform-origin: 50% 100%;
  transition: opacity 0.2s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s 0.35s;
}
.hfx-emoji-reactions-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 0.6em;
}
.hfx-emoji-reactions-bar button {
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  padding: 0;
  border: 0;
  background: none;
  font-size: 1.35em;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(0.6em) scale(0.3);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}
.hfx-emoji-reactions:is(:hover, :focus-within) .hfx-emoji-reactions-like { background: color-mix(in srgb, var(--c) 16%, transparent); }
.hfx-emoji-reactions:is(:hover, :focus-within) .hfx-emoji-reactions-bar {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%);
  transition-delay: 0s;
}
.hfx-emoji-reactions:is(:hover, :focus-within) .hfx-emoji-reactions-bar button {
  opacity: 1;
  transform: none;
  transition-delay: calc(0.04s + var(--i) * 0.035s);
}
.hfx-emoji-reactions .hfx-emoji-reactions-bar button:is(:hover, :focus-visible) {
  transform: translateY(-0.3em) scale(1.35);
  transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
  .hfx-emoji-reactions, .hfx-emoji-reactions *, .hfx-emoji-reactions::before, .hfx-emoji-reactions::after, .hfx-emoji-reactions *::before, .hfx-emoji-reactions *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar hover effects