The effect

Adam Argyle's CodePen demo shows a hover highlight that slides in from the left on mouse-in and leaves through the right on mouse-out — a directional behavior that reads as unusually app-like for a link. Recreating it doesn't require anything exotic: it's a combination of transitions, transforms and the right offsets.

Why a plain background transition falls short

The obvious first approach is to set a background color, define background-size and background-position, and transition the position — the usual way to grow a background color. That works for one direction only. Nothing makes background-position animate left-to-right on entry and left-to-right again on exit; you get one or the other, not both.

A transform opens up scaleX(), but applying it to the anchor scales the entire element — text included — squishing the link down to nothing and stretching it back. It also means defaulting to scaleX(0), which hides the whole thing and makes it unusable. Neither problem matters on a pseudo-element, which isn't part of the real content. So the background belongs on ::before, positioned directly under the link.

a {
  /* Keeps the pseudo-element contained to the element */
  position: relative;
}

a::before {
  background: #ff9800;
  content: "";
  inset: 0; /* Logical equivalent to physical offsets */
  position: absolute;
  transform: scaleX(0); /* Hide by default */
  z-index: -1; /* Ensures the link is stacked on top */
}

Hooking the pseudo-element to hover

Chaining ::before to the link's :hover state lets it scale from 0 to 1.

a:hover::before {
  transform: scaleX(1)
}

Adding a transition brings it to life.

a::before {
  background: #ff9800;
  content: "";
  inset: 0;
  position: absolute;
  transform: scaleX(0);
  transition: transform .5s ease-in-out;
  z-index: -1;
}

Controlling the exit direction

By default the transition runs in both directions along the same path, so the highlight retreats the way it arrived. The missing piece is transform-origin, which sets where the transform starts — conceptually similar to the background-position idea tried earlier, but it can pull the origin from the left instead of the default 50% 50%.

a::before {
  background: #ff9800;
  content: "";
  inset: 0;
  position: absolute;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .5s ease-in-out;
  z-index: -1;
}

The trick is to change transform-origin from left to right at the same moment ::before transitions to scaleX(1) on hover. If the values are set the wrong way round, the animation runs backwards; swapping left and right corrects it.

a:hover::before {
  transform: scaleX(1);
  transform-origin: right;
}