AI CSS Animations

Corner Brackets Button

Four corner brackets frame a tinted button. On hover they spring outward with a little overshoot, like a viewfinder widening, and the tint deepens. The brackets are eight gradients on one pseudo.

Also known as: corner border hover, viewfinder button, bracket corners css.

HTML

<button class="btn-corner-brackets">Scan code</button>

CSS

.btn-corner-brackets {
  --c: var(--btn-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font: 600 var(--btn-size, 18px)/1.2 system-ui, sans-serif;
  cursor: pointer;
  position: relative;
  padding: 0.85em 1.8em;
  border: 0;
  border-radius: 0.2em;
  background-color: color-mix(in srgb, var(--c) 8%, transparent);
  color: var(--c);
  transition: background-color 0.3s ease;}
.btn-corner-brackets::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--c) 0 0) top left / 0.75em 2px,
    linear-gradient(var(--c) 0 0) top left / 2px 0.75em,
    linear-gradient(var(--c) 0 0) top right / 0.75em 2px,
    linear-gradient(var(--c) 0 0) top right / 2px 0.75em,
    linear-gradient(var(--c) 0 0) bottom left / 0.75em 2px,
    linear-gradient(var(--c) 0 0) bottom left / 2px 0.75em,
    linear-gradient(var(--c) 0 0) bottom right / 0.75em 2px,
    linear-gradient(var(--c) 0 0) bottom right / 2px 0.75em;
  background-repeat: no-repeat;
  pointer-events: none;
  transition: inset 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-corner-brackets:is(:hover, :focus-visible) { background-color: color-mix(in srgb, var(--c) 16%, transparent); }
.btn-corner-brackets:is(:hover, :focus-visible)::before { inset: -0.45em -0.6em; }

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

Customizing this snippet

  • Color: set --btn-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --btn-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 18px.
  • 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 buttons