AI CSS Animations

Corner Brackets Fill Button

Four corner brackets frame the label like a viewfinder; on hover they thicken and reach inward until they tile a solid fill. Eight gradient layers and one background-size transition.

Also known as: four corners fill hover, viewfinder button, corner border button.

HTML

<button class="hfx-corner-brackets-fill">Take a tour</button>

CSS

.hfx-corner-brackets-fill {
  --c: var(--hfx-color, #3b82f6);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.75em;
  border-radius: 0.3em;
  font: 600 var(--hfx-size, 16px)/1.2 system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--c);
  transition: color 0.25s ease 0.12s;
}
.hfx-corner-brackets-fill::before {
  --arm: 0.9em;
  --t: 0.16em;
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(var(--c) 0 0) 0 0,
    linear-gradient(var(--c) 0 0) 0 0,
    linear-gradient(var(--c) 0 0) 100% 0,
    linear-gradient(var(--c) 0 0) 100% 0,
    linear-gradient(var(--c) 0 0) 0 100%,
    linear-gradient(var(--c) 0 0) 0 100%,
    linear-gradient(var(--c) 0 0) 100% 100%,
    linear-gradient(var(--c) 0 0) 100% 100%;
  background-repeat: no-repeat;
  background-size:
    var(--arm) var(--t), var(--t) var(--arm),
    var(--arm) var(--t), var(--t) var(--arm),
    var(--arm) var(--t), var(--t) var(--arm),
    var(--arm) var(--t), var(--t) var(--arm);
  transition: background-size 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.hfx-corner-brackets-fill:is(:hover, :focus-visible) { color: #fff; }
.hfx-corner-brackets-fill:is(:hover, :focus-visible)::before {
  background-size: 51% 51%;
}

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