AI CSS Animations

Split Reveal Text Hover

The word splits along its middle and the halves part up and down to show a small line of text hidden inside. Both halves are one data attribute clipped two ways with clip-path.

Also known as: split text hover, hidden text reveal on hover, text halves slide apart.

Studio Since 2014

HTML

<div class="hfx-text-split-reveal" data-text="Studio">
  <span class="hfx-text-split-reveal-word">Studio</span>
  <span class="hfx-text-split-reveal-hidden">Since 2014</span>
</div>

CSS

.hfx-text-split-reveal {
  --c: var(--hfx-color, #3b82f6);
  font-size: calc(var(--hfx-size, 16px) * 2.5);
  font-family: system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.15;
  cursor: default;
  position: relative;
  display: inline-grid;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;}
.hfx-text-split-reveal-word { color: transparent; }
.hfx-text-split-reveal::before,
.hfx-text-split-reveal::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  transition: transform 0.5s cubic-bezier(0.76, 0, 0.24, 1);
}
.hfx-text-split-reveal::before { clip-path: inset(0 0 43% 0); }
.hfx-text-split-reveal::after { clip-path: inset(57% 0 0 0); }
.hfx-text-split-reveal-hidden {
  position: absolute;
  inset: 0.14em 0 0;
  display: grid;
  place-items: center;
  padding-left: 0.3em;
  font-size: 0.3em;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--c);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.76, 0, 0.24, 1);
}
.hfx-text-split-reveal:hover::before { transform: translateY(-0.4em); }
.hfx-text-split-reveal:hover::after { transform: translateY(0.4em); }
.hfx-text-split-reveal:hover .hfx-text-split-reveal-hidden {
  opacity: 1;
  transform: none;
  transition-delay: 0.1s;
}

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