Adventureland Registry

Blinking Cursor

A GSAP-animated blinking cursor rendered as a thin inline span, with imperative controls exposed via ref.

BlinkingCursor renders a styled <span> that blinks continuously using a GSAP timeline. It accepts a forwarded ref so parent components can call stopBlinking(), startBlinking(), and resetCursor() imperatively — useful when pairing it with typewriter or streaming-text effects.

Installation

npx shadcn@latest add @adv/blinking-cursor

Usage

import { BlinkingCursor } from '@/components/BlinkingCursor';

<span className="inline-flex items-center">
  Hello world
  <BlinkingCursor />
</span>

Example

Hello world

Props

PropTypeDefaultDescription
classNamestring"inline-block bg-foreground ml-1 h-7 -mb-1 rounded-sm"CSS classes for the cursor span.
widthnumber2Width of the cursor in pixels.
heightnumber28Height of the cursor in pixels.
blinkSpeednumber0.5Duration (in seconds) of each fade half-cycle.
blinkEasestring"power2.inOut"GSAP ease applied to each blink step.
isVisiblebooleantrueWhether the cursor is visible and animating.
onBlinkStart() => voidCallback fired when blinking begins.
onBlinkStop() => voidCallback fired when blinking stops.

Imperative ref methods

When you attach a ref to BlinkingCursor, the DOM node is extended with three methods:

MethodDescription
stopBlinking()Gradually fades and desaturates the cursor to signal completion.
startBlinking()Resets any fade state and restarts the blink loop.
resetCursor()Kills all animations and restores the cursor to full opacity.

On this page