AI CSS Animations

Spotlight Card Hover

A dark card where a soft spotlight glides in from the corner and settles at the top, lighting the border as it passes. Two registered @property percentages move one radial gradient.

Also known as: spotlight hover effect css, radial gradient card hover, glowing card border hover.

Analytics

See every signal

Live dashboards that update the moment your data lands.

HTML

<article class="hfx-card-spotlight">
  <span class="hfx-card-spotlight-eyebrow">Analytics</span>
  <h3>See every signal</h3>
  <p>Live dashboards that update the moment your data lands.</p>
</article>

CSS

@property --hfx-card-spotlight-x {
  syntax: "<percentage>";
  inherits: true;
  initial-value: -30%;
}
@property --hfx-card-spotlight-y {
  syntax: "<percentage>";
  inherits: true;
  initial-value: -60%;
}
.hfx-card-spotlight {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  --hfx-card-spotlight-x: -30%;
  --hfx-card-spotlight-y: -60%;
  position: relative;
  box-sizing: border-box;
  width: 15em;
  padding: 1.25em 1.3em 1.35em;
  overflow: hidden;
  border-radius: 0.9em;
  background: #0d0f14;
  color: #f3f4f6;
  font-family: system-ui, sans-serif;
  transition: --hfx-card-spotlight-x 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), --hfx-card-spotlight-y 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hfx-card-spotlight:hover {
  --hfx-card-spotlight-x: 62%;
  --hfx-card-spotlight-y: 0%;
}
.hfx-card-spotlight::before,
.hfx-card-spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}
.hfx-card-spotlight::before {
  background: radial-gradient(circle 11em at var(--hfx-card-spotlight-x) var(--hfx-card-spotlight-y), color-mix(in srgb, var(--c) 55%, transparent), transparent 70%);
}
.hfx-card-spotlight::after {
  padding: 1px;
  background: radial-gradient(circle 9em at var(--hfx-card-spotlight-x) var(--hfx-card-spotlight-y), var(--c), color-mix(in srgb, #fff 12%, transparent) 75%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.hfx-card-spotlight > * { position: relative; }
.hfx-card-spotlight-eyebrow {
  font-size: 0.65em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--c) 55%, #fff);
}
.hfx-card-spotlight h3 {
  font-weight: 600;
  margin: 0.45em 0 0.3em;
  font-size: 1.05em;
}
.hfx-card-spotlight p {
  margin: 0;
  font-size: 0.8em;
  line-height: 1.45;
  color: color-mix(in srgb, #fff 60%, transparent);
}

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