HoverLab

Segmented Magnetic Pulse

Four border segments pulse outward independently in a magnetic breathing rhythm.

Live demo

Hover the buttons to see the effect.

Customize in HoverLab → ☕ Buy me a coffee

How to use this effect

Paste the HTML into your page and the CSS into your stylesheet. Change --btn-color, --btn-bg and --anim-speed to match your design.

HTML
<button class="hover-btn btn-size-md btn-hover-snap-frame">
  <span>HoverLab</span>
  <svg class="btn-icon btn-icon-right" width="18" height="18" viewBox="0 0 256 256" fill="currentColor"><path d="M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"></path></svg>
</button>
CSS
/* ==========================================
   HoverLab Effect #44: 44. Segmented Magnetic Pulse
   Self-Contained & Plug-and-Play CSS
   ========================================== */

:root {
  --btn-color: #e6332a;
  --btn-bg: #eeeeee;
  --anim-speed: 0.35s;
}

/* Base Button Styles */
.hover-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 28px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  background-color: transparent;
  color: var(--btn-color, #e6332a);
  border: 1.5px solid var(--btn-color, #e6332a);
  border-radius: 9999px;
  text-decoration: none;
  user-select: none;
  transition: all var(--anim-speed, 0.35s) cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.hover-btn.btn-icon-only {
  padding: 0 !important;
  aspect-ratio: 1 / 1;
  width: 44px;
  height: 44px;
}

.hover-btn .btn-icon {
  display: block;
  flex-shrink: 0;
  transition: transform var(--anim-speed, 0.35s) cubic-bezier(0.16, 1, 0.3, 1);
}

/* Effect Styles */
@keyframes segmentPulseTop {
  0%, 100% {
    transform: translateY(0) scaleX(1);
  }
  50% {
    transform: translateY(-4px) scaleX(1.06);
  }
}

@keyframes segmentPulseRight {
  0%, 100% {
    transform: translateX(0) scaleY(1);
  }
  50% {
    transform: translateX(4px) scaleY(1.06);
  }
}

@keyframes segmentPulseBottom {
  0%, 100% {
    transform: translateY(0) scaleX(1);
  }
  50% {
    transform: translateY(4px) scaleX(1.06);
  }
}

@keyframes segmentPulseLeft {
  0%, 100% {
    transform: translateX(0) scaleY(1);
  }
  50% {
    transform: translateX(-4px) scaleY(1.06);
  }
}

.btn-hover-snap-frame {
  position: relative;
  transition: transform var(--anim-speed, 0.28s) cubic-bezier(0.16, 1, 0.3, 1),
              background-color var(--anim-speed, 0.25s) ease,
              box-shadow var(--anim-speed, 0.28s) ease;
}

.btn-hover-snap-frame::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 15%;
  right: 15%;
  height: 1.5px;
  background-color: var(--btn-color, #18181b);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--anim-speed, 0.2s) ease;
}

.btn-hover-snap-frame::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 15%;
  right: 15%;
  height: 1.5px;
  background-color: var(--btn-color, #18181b);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--anim-speed, 0.2s) ease;
}

.btn-hover-snap-frame:hover::before {
  opacity: 1;
  animation: segmentPulseTop var(--anim-speed, 0.8s) cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.btn-hover-snap-frame:hover::after {
  opacity: 1;
  animation: segmentPulseBottom var(--anim-speed, 0.8s) cubic-bezier(0.16, 1, 0.3, 1) infinite;
  animation-delay: 0.1s;
}

.btn-hover-snap-frame:hover {
  transform: translateY(-2px);
  background-color: #18181b0a;
  box-shadow: 0 8px 24px -4px #0000001f,
              4px 0 0 0 var(--btn-color, #18181b),
              -4px 0 0 0 var(--btn-color, #18181b);
  animation: segmentSidePulse var(--anim-speed, 0.8s) cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

@keyframes segmentSidePulse {
  0%, 100% {
    box-shadow: 0 8px 24px -4px #0000001f,
                4px 0 0 0 var(--btn-color, #18181b),
                -4px 0 0 0 var(--btn-color, #18181b);
  }
  50% {
    box-shadow: 0 8px 24px -4px #0000001f,
                8px 0 0 0 var(--btn-color, #18181b),
                -8px 0 0 0 var(--btn-color, #18181b);
  }
}

.btn-hover-snap-frame:active {
  transform: translateY(0);
}

.btn-hover-snap-frame .btn-icon {
  transition: transform var(--anim-speed, 0.28s) cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-hover-snap-frame:hover .btn-icon {
  transform: translateX(4px) scale(1.12);
}

When to use it

Border effects animate only the outline and leave the label untouched. They suit secondary and ghost buttons, navigation and cards, where the hover cue should stay quiet next to a primary action.

Accessibility

Use a real <button> or <a> element so the effect also works with the keyboard: duplicate the :hover selectors with :focus-visible. For visitors who prefer less motion, wrap the transitions and animations in @media (prefers-reduced-motion: no-preference).

Browser support

The effect relies on standard CSS (transitions, transforms, pseudo-elements and custom properties). It works in current versions of Chrome, Edge, Firefox and Safari, with no JavaScript and no dependency.

More Borders & Outlines effects