AI CSS Animations

Bracket Link

Square brackets slide in from either side to wrap the text, a nod to terminal and code aesthetics. The brackets are pseudo-element content, so they never touch the copy.

Also known as: brackets on hover, code style link.

HTML

<a class="hfx-link-bracket" href="#">Changelog</a>

CSS

.hfx-link-bracket {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  display: inline-block;
  color: var(--c);
  font: 600 1em system-ui, sans-serif;
  text-decoration: none;
  padding: 0 0.6em;}
.hfx-link-bracket::before,
.hfx-link-bracket::after {
  position: absolute;
  top: 0;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.hfx-link-bracket::before { content: "["; left: 0;  transform: translateX(-0.4em); }
.hfx-link-bracket::after  { content: "]"; right: 0; transform: translateX(0.4em); }
.hfx-link-bracket:hover::before,
.hfx-link-bracket:hover::after {
  opacity: 1;
  transform: translateX(0);
}

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

Underline Grow Link
Underline from Center Link
Highlighter Link
Slide Up Text Link