26 CSS Link Effects12 / 26

Pure CSSMIT licensed

CSS Blinking Cursor Underline Hover Effect

Terminal-native link affordances for dev tools, docs and portfolio sites: a block caret that starts blinking beside the link on hover, an underline that types itself in discrete steps before the caret appears at its end, and a prompt chevron that slides in like a fresh shell line. Blinks use steps(1) — the authentic square-wave flicker, not a fade.

Published Updated

Live Demo
Try it

The code

<section class="cle-12" aria-label="Blinking cursor link demo">
  <div class="cle-12__stage">
    <div class="cle-12__screen" role="presentation">
      <p class="cle-12__line"><span class="cle-12__dim">visitor@codefronts:~$</span> ls ./guides</p>
      <ul class="cle-12__list">
        <li><a href="#a" class="cle-12__caret">deploy-checklist.md</a><small class="cle-12__cap">A · block caret blinks</small></li>
        <li><a href="#b" class="cle-12__typed">shell-profiles.md</a><small class="cle-12__cap">B · underline types, then blinks</small></li>
        <li><a href="#c" class="cle-12__prompt"><span class="cle-12__chev" aria-hidden="true">›</span>ssh-hardening.md</a><small class="cle-12__cap">C · prompt slides in</small></li>
      </ul>
    </div>
  </div>
</section>
.cle-12,
.cle-12 *,
.cle-12 *::before,
.cle-12 *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.cle-12 {
  width: 100%;
  min-height: 100vh;
  --term: oklch(0.85 0.19 150);
  --dim: oklch(0.62 0.06 150);
  font-family: ui-monospace,'Cascadia Code',Menlo,Consolas,monospace;
}

.cle-12__stage {
  width: 100%;
  height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 130% at 50% 0%,oklch(0.23 0.03 155),oklch(0.16 0.02 160) 65%);
  padding: 44px 32px;
}

.cle-12__screen {
  width: min(560px,100%);
  border-radius: 14px;
  border: 1px solid oklch(0.4 0.05 150 / .5);
  background: oklch(0.13 0.015 160 / .85);
  padding: 28px 30px;
  box-shadow: 0 30px 60px -30px oklch(0 0 0 / .6),inset 0 1px 0 oklch(0.5 0.06 150 / .25);
}

.cle-12__line {
  color: var(--term);
  font-size: 14.5px;
  margin-bottom: 20px;
}

.cle-12__dim {
  color: var(--dim);
}

.cle-12__list {
  list-style: none;
  display: grid;
  gap: 18px;
}

.cle-12__list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.cle-12__cap {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  font-family: 'Segoe UI',system-ui,sans-serif;
}

.cle-12 a {
  color: oklch(0.9 0.06 150);
  text-decoration: none;
  font-size: 16px;
  transition: color .2s;
}

.cle-12 a:hover,
.cle-12 a:focus-visible {
  color: var(--term);
}

.cle-12 a:focus-visible {
  outline: 1.5px solid var(--term);
  outline-offset: 4px;
}

.cle-12 a::selection {
  background: oklch(0.85 0.19 150 / .35);
}

.cle-12__caret::after {
  content: "";
  display: inline-block;
  width: .55ch;
  height: 1.05em;
  margin-left: .35ch;
  vertical-align: text-bottom;
  background: var(--term);
  opacity: 0;
}

.cle-12__caret:hover::after,
.cle-12__caret:focus-visible::after {
  animation: clh12-blink 1.1s steps(1) infinite;
}

.cle-12__typed {
  padding-bottom: 5px;
  background: linear-gradient(var(--term),var(--term)) no-repeat left bottom / 0% 2px;
  transition: background-size .4s steps(10,end);
}

.cle-12__typed:hover,
.cle-12__typed:focus-visible {
  background-size: 100% 2px;
}

.cle-12__typed::after {
  content: "";
  display: inline-block;
  width: .55ch;
  height: 1.05em;
  margin-left: .35ch;
  vertical-align: text-bottom;
  background: var(--term);
  opacity: 0;
}

.cle-12__typed:hover::after,
.cle-12__typed:focus-visible::after {
  animation: clh12-blink 1.1s steps(1) .4s infinite;
}

.cle-12__prompt .cle-12__chev {
  display: inline-block;
  width: 0;
  overflow: hidden;
  color: var(--term);
  translate: -8px 0;
  opacity: 0;
  transition: width .3s,translate .3s cubic-bezier(.3,1.3,.4,1),opacity .25s;
  vertical-align: baseline;
}

.cle-12__prompt:hover .cle-12__chev,
.cle-12__prompt:focus-visible .cle-12__chev {
  width: 1.4ch;
  translate: 0 0;
  opacity: 1;
}

@keyframes clh12-blink {
  0%,
    49% {
    opacity: 1;
  }

  50%,
    100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cle-12 * {
    transition-duration: .01s !important;
    animation: none !important;
  }

  .cle-12__caret:hover::after,
    .cle-12__typed:hover::after {
    opacity: 1;
  }
}
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
Here's a working CSS Link Effect from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: CSS Blinking Cursor Underline Hover Effect
Source: https://codefronts.com/motion/css-link-effects/cursor-blink-underline/

Terminal-native link affordances for dev tools, docs and portfolio sites: a block caret that starts blinking beside the link on hover, an underline that types itself in discrete steps before the caret appears at its end, and a prompt chevron that slides in like a fresh shell line. Blinks use steps(1) — the authentic square-wave flicker, not a fade.
## HTML
```html
<section class="cle-12" aria-label="Blinking cursor link demo">
  <div class="cle-12__stage">
    <div class="cle-12__screen" role="presentation">
      <p class="cle-12__line"><span class="cle-12__dim">visitor@codefronts:~$</span> ls ./guides</p>
      <ul class="cle-12__list">
        <li><a href="#a" class="cle-12__caret">deploy-checklist.md</a><small class="cle-12__cap">A · block caret blinks</small></li>
        <li><a href="#b" class="cle-12__typed">shell-profiles.md</a><small class="cle-12__cap">B · underline types, then blinks</small></li>
        <li><a href="#c" class="cle-12__prompt"><span class="cle-12__chev" aria-hidden="true">›</span>ssh-hardening.md</a><small class="cle-12__cap">C · prompt slides in</small></li>
      </ul>
    </div>
  </div>
</section>
```
## CSS
```css
.cle-12,
.cle-12 *,
.cle-12 *::before,
.cle-12 *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.cle-12 {
  width: 100%;
  min-height: 100vh;
  --term: oklch(0.85 0.19 150);
  --dim: oklch(0.62 0.06 150);
  font-family: ui-monospace,'Cascadia Code',Menlo,Consolas,monospace;
}

.cle-12__stage {
  width: 100%;
  height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 130% at 50% 0%,oklch(0.23 0.03 155),oklch(0.16 0.02 160) 65%);
  padding: 44px 32px;
}

.cle-12__screen {
  width: min(560px,100%);
  border-radius: 14px;
  border: 1px solid oklch(0.4 0.05 150 / .5);
  background: oklch(0.13 0.015 160 / .85);
  padding: 28px 30px;
  box-shadow: 0 30px 60px -30px oklch(0 0 0 / .6),inset 0 1px 0 oklch(0.5 0.06 150 / .25);
}

.cle-12__line {
  color: var(--term);
  font-size: 14.5px;
  margin-bottom: 20px;
}

.cle-12__dim {
  color: var(--dim);
}

.cle-12__list {
  list-style: none;
  display: grid;
  gap: 18px;
}

.cle-12__list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.cle-12__cap {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  font-family: 'Segoe UI',system-ui,sans-serif;
}

.cle-12 a {
  color: oklch(0.9 0.06 150);
  text-decoration: none;
  font-size: 16px;
  transition: color .2s;
}

.cle-12 a:hover,
.cle-12 a:focus-visible {
  color: var(--term);
}

.cle-12 a:focus-visible {
  outline: 1.5px solid var(--term);
  outline-offset: 4px;
}

.cle-12 a::selection {
  background: oklch(0.85 0.19 150 / .35);
}

.cle-12__caret::after {
  content: "";
  display: inline-block;
  width: .55ch;
  height: 1.05em;
  margin-left: .35ch;
  vertical-align: text-bottom;
  background: var(--term);
  opacity: 0;
}

.cle-12__caret:hover::after,
.cle-12__caret:focus-visible::after {
  animation: clh12-blink 1.1s steps(1) infinite;
}

.cle-12__typed {
  padding-bottom: 5px;
  background: linear-gradient(var(--term),var(--term)) no-repeat left bottom / 0% 2px;
  transition: background-size .4s steps(10,end);
}

.cle-12__typed:hover,
.cle-12__typed:focus-visible {
  background-size: 100% 2px;
}

.cle-12__typed::after {
  content: "";
  display: inline-block;
  width: .55ch;
  height: 1.05em;
  margin-left: .35ch;
  vertical-align: text-bottom;
  background: var(--term);
  opacity: 0;
}

.cle-12__typed:hover::after,
.cle-12__typed:focus-visible::after {
  animation: clh12-blink 1.1s steps(1) .4s infinite;
}

.cle-12__prompt .cle-12__chev {
  display: inline-block;
  width: 0;
  overflow: hidden;
  color: var(--term);
  translate: -8px 0;
  opacity: 0;
  transition: width .3s,translate .3s cubic-bezier(.3,1.3,.4,1),opacity .25s;
  vertical-align: baseline;
}

.cle-12__prompt:hover .cle-12__chev,
.cle-12__prompt:focus-visible .cle-12__chev {
  width: 1.4ch;
  translate: 0 0;
  opacity: 1;
}

@keyframes clh12-blink {
  0%,
    49% {
    opacity: 1;
  }

  50%,
    100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cle-12 * {
    transition-duration: .01s !important;
    animation: none !important;
  }

  .cle-12__caret:hover::after,
    .cle-12__typed:hover::after {
    opacity: 1;
  }
}
```

How this works

A real terminal caret doesn't fade — it's binary. steps(1) (equivalently steps(1, jump-start) here) holds each keyframe value with no interpolation:

.caret::after{ content:""; width:.55ch; height:1.05em;
  background: var(--term); opacity: 0; }
.caret:hover::after{ animation: clh12-blink 1.1s steps(1) infinite; }
@keyframes clh12-blink{ 0%,49%{opacity:1} 50%,100%{opacity:0} }

B choreographs two beats with one property each: the underline is a gradient background whose background-size transitions 0%→100% with steps(10, end) as the transition timing function (steps work on transitions, not just animations — the underline draws in 10 discrete chunks like typed characters), then the end-caret's blink animation starts after a matching animation-delay. C slides the prompt glyph in from the left while the caret lands after the label. Everything sits on a ch-unit grid so widths line up with the monospace glyphs.

Make it yours

  • Blink cadence: the 1.1s loop (VT220s blinked at ~1.06s; you're in good company).
  • Caret shape: .55ch block, or drop height to 2px for an underscore caret.
  • B's typing granularity: steps(10) ≈ one chunk per character of a 10-char label — match it to your text length.
  • Phosphor color: one --term token; try amber oklch(0.8 0.17 80) for the P3 CRT look.

Gotchas — read before shipping

  • prefers-reduced-motion must not remove the affordance: the demo swaps the blink for a steady lit caret (animation:none; opacity:1), which still signals interactivity.
  • The block caret is layout-participating (inline-block), so it needs margin-left in ch units to sit on the character grid — don't absolutely position it or it drifts from wrapped text.
  • steps() on the transition draws the line in chunks but the *reverse* (mouse-out) also steps; if that feels raspy, split enter/exit timing functions.

Browser support

ChromeSafariFirefoxEdge
111+16.2+113+111+

steps() easing, ch units and gradient underlines are ancient; everything here is Baseline years back. oklch sets the stated floor — swap to hex for legacy terminals… browsers.

Search CodeFronts

Loading…