AI CSS Animations

Holographic Border

A pastel foil border whose colors slide as if the card were tilting under a light, with a white sheen crossing the other way. Two background layers ease back and forth on alternate loops.

Also known as: iridescent border css, holo foil border, holographic gradient border.

Holographic

HTML

<div class="bdr-holographic-border">Holographic</div>

CSS

.bdr-holographic-border {
  --c: var(--bdr-color, #3b82f6);
  font-size: var(--bdr-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 15em;
  height: 8.5em;
  border-radius: 1em;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  background: color-mix(in srgb, var(--c) 8%, #0d0f16);
  color: #f8fafc;
}
.bdr-holographic-border::before,
.bdr-holographic-border::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(115deg, transparent 38%, rgb(255 255 255 / 0.9) 50%, transparent 62%) 100% 0 / 300% 100% no-repeat,
    linear-gradient(60deg, #f9a8d4, color-mix(in srgb, var(--c) 45%, #fff), #6ee7b7, #fde047, #c4b5fd, #f0abfc, #f9a8d4) 0 0 / 300% 300%;
  pointer-events: none;
  animation: bdr-holographic-border-tilt 4s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
.bdr-holographic-border::before {
  padding: 0.3em;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.bdr-holographic-border::after { opacity: 0.12; }
@keyframes bdr-holographic-border-tilt {
  from { background-position: 100% 0, 0% 0%; }
  to   { background-position: 0% 0, 100% 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .bdr-holographic-border, .bdr-holographic-border *, .bdr-holographic-border::before, .bdr-holographic-border::after, .bdr-holographic-border *::before, .bdr-holographic-border *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --bdr-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --bdr-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 border animations