AI CSS Animations

Profile Card Social Icons Hover

A profile card whose role line slides away and a row of social icons springs up in its place, one after another. The swap happens in a fixed-height slot, so the card never resizes.

Also known as: profile card hover effect, team member card css, social icons reveal on hover.

AR

Ana Ribeiro

Product designer, Lisbon

HTML

<article class="hfx-card-profile-social">
  <div class="hfx-card-profile-social-avatar">AR</div>
  <h3>Ana Ribeiro</h3>
  <div class="hfx-card-profile-social-swap">
    <p>Product designer, Lisbon</p>
    <nav class="hfx-card-profile-social-links" aria-label="Ana on the web">
      <a href="#" style="--i: 0" aria-label="Email"><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg></a>
      <a href="#" style="--i: 1" aria-label="Website"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3.5 3.5 3.5 14.5 0 18M12 3c-3.5 3.5-3.5 14.5 0 18"/></svg></a>
      <a href="#" style="--i: 2" aria-label="Photos"><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="7" width="18" height="13" rx="3"/><circle cx="12" cy="13.5" r="3.5"/><path d="M8.5 7 10 4.5h4L15.5 7"/></svg></a>
    </nav>
  </div>
</article>

CSS

.hfx-card-profile-social {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  width: 15em;
  border-radius: 0.75em;
  overflow: hidden;
  background: #fff;
  border: 1px solid color-mix(in srgb, #000 10%, transparent);
  color: #1f2937;
  font-family: system-ui, sans-serif;
  box-sizing: border-box;
  width: 12em;
  padding: 1.2em 1em 0.9em;
  text-align: center;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease;}
.hfx-card-profile-social:is(:hover, :focus-within) {
  transform: translateY(-0.25em);
  box-shadow: 0 0.9em 1.4em -0.9em color-mix(in srgb, #000 35%, transparent);
}
.hfx-card-profile-social-avatar {
  display: grid;
  place-items: center;
  width: 3.4em;
  height: 3.4em;
  margin: 0 auto 0.65em;
  border-radius: 50%;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 45%, #fff), var(--c));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 0 0.2em #fff, 0 0 0 0.2em color-mix(in srgb, var(--c) 0%, transparent);
  transition: box-shadow 0.35s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hfx-card-profile-social:is(:hover, :focus-within) .hfx-card-profile-social-avatar {
  transform: scale(1.06);
  box-shadow: 0 0 0 0.2em #fff, 0 0 0 0.36em var(--c);
}
.hfx-card-profile-social h3 {
  font-weight: 600;
  margin: 0;
  font-size: 1em;
}
.hfx-card-profile-social-swap {
  display: grid;
  height: 2.3em;
  margin-top: 0.3em;
  overflow: hidden;
}
.hfx-card-profile-social-swap > * { grid-area: 1 / 1; }
.hfx-card-profile-social-swap p {
  align-self: center;
  margin: 0;
  font-size: 0.8em;
  color: #6b7280;
  transition: transform 0.3s ease, opacity 0.25s ease;
}
.hfx-card-profile-social:is(:hover, :focus-within) .hfx-card-profile-social-swap p {
  transform: translateY(-1.6em);
  opacity: 0;
}
.hfx-card-profile-social-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
}
.hfx-card-profile-social-links a {
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 12%, transparent);
  color: var(--c);
  opacity: 0;
  transform: translateY(1.6em);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease, background-color 0.2s ease, color 0.2s ease;
}
.hfx-card-profile-social:is(:hover, :focus-within) .hfx-card-profile-social-links a {
  opacity: 1;
  transform: none;
  transition-delay: calc(var(--i) * 70ms + 60ms);
}
.hfx-card-profile-social-links a:is(:hover, :focus-visible) {
  background: var(--c);
  color: #fff;
}
.hfx-card-profile-social-links svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (prefers-reduced-motion: reduce) {
  .hfx-card-profile-social, .hfx-card-profile-social *, .hfx-card-profile-social::before, .hfx-card-profile-social::after, .hfx-card-profile-social *::before, .hfx-card-profile-social *::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