AI CSS Animations

Side Tooltip Hover Effect

A vertical toolbar whose labels unroll to the right of each icon on hover. The label is wiped in with clip-path from the icon's edge, so it reads as coming out of the button.

Also known as: tooltip on the right css, sidebar icon tooltip, slide out label on hover.

HTML

<nav class="hfx-tooltip-side-slide" aria-label="Toolbar">
  <a href="#" aria-label="Home" data-tip="Home"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 10.5 12 4l8 6.5V19a1.5 1.5 0 0 1-1.5 1.5H15v-6H9v6H5.5A1.5 1.5 0 0 1 4 19z"/></svg></a>
  <a href="#" aria-label="Search" data-tip="Search"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="6.5"/><path d="m20 20-4.2-4.2"/></svg></a>
  <a href="#" aria-label="Notifications" data-tip="Notifications"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 8.5a6 6 0 0 1 12 0c0 6.5 2.5 8 2.5 8h-17S6 15 6 8.5"/><path d="M10.3 20a2 2 0 0 0 3.4 0"/></svg></a>
</nav>

CSS

.hfx-tooltip-side-slide {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  margin-right: 7em; /* room for the labels in this preview */
  padding: 0.4em;
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
  border-radius: 0.9em;
  background: color-mix(in srgb, var(--c) 7%, transparent);
  font-family: system-ui, sans-serif;
}
.hfx-tooltip-side-slide a {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.5em;
  height: 2.5em;
  border-radius: 0.6em;
  color: color-mix(in srgb, currentColor 70%, transparent);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.hfx-tooltip-side-slide svg { width: 1.2em; height: 1.2em; }
.hfx-tooltip-side-slide a::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 0.9em);
  top: 50%;
  padding: 0.4em 0.75em;
  border-radius: 0.45em;
  background: var(--c);
  color: #fff;
  font-size: 0.8em;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  clip-path: inset(0 100% 0 0 round 0.45em);
  transform: translate(-0.5em, -50%);
  transition: clip-path 0.3s cubic-bezier(0.65, 0, 0.35, 1), transform 0.3s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.hfx-tooltip-side-slide a::before {
  content: "";
  position: absolute;
  left: calc(100% + 0.5em);
  top: 50%;
  border: 0.35em solid transparent;
  border-right-color: var(--c);
  opacity: 0;
  transform: translate(-0.4em, -50%);
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.hfx-tooltip-side-slide a:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--c) 15%, transparent);
  color: var(--c);
}
.hfx-tooltip-side-slide a:is(:hover, :focus-visible)::after {
  clip-path: inset(0 0 0 0 round 0.45em);
  transform: translate(0, -50%);
}
.hfx-tooltip-side-slide a:is(:hover, :focus-visible)::before {
  opacity: 1;
  transform: translate(0, -50%);
}

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

Sliding Pill Nav Hover Effect
Directional Underline Nav Hover Effect
Dot Indicator Nav Hover Effect
Vertical Nav Indicator Hover Effect