Skip to content
animorio
IT
Back to the library

Ghost text autocomplete

Text, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.1 KBGSAP 28 KBFreeDownload the zip

AI autocomplete in the email editor of Quire, a made-up writing app, the way real editors do it: while the text types itself, after a pause a light grey suggestion appears after the caret, one word at a time out of a slight blur, with a drawn Tab key beside it. Tab turns it into ink with a pale light running across it and the caret jumps to the end; Esc pulls it back from its last word; Cmd or Ctrl with the right arrow takes it one word at a time. It works with the real keyboard too. Minimal style, a single accent.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Ghost text autocomplete" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Ghost text autocomplete</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- The email editor of a made-up writing app, Quire, with AI autocomplete like real editors: while the text types
       itself, a grey suggestion (ghost text) fades in after the caret word by word, with a small Tab key beside it.
       Tab turns the grey into ink with a light running across it and the caret jumps to the end; Esc pulls the
       suggestion back; Cmd or Ctrl + right arrow takes it one word at a time. It also works with the real keyboard. -->
  <main class="stage">
    <article class="editor" data-editor aria-label="Email draft with AI suggestions">
      <header class="editor__head">
        <div class="app">
          <span class="app__mark" aria-hidden="true">
            <svg viewBox="0 0 20 20"><path d="M10 3.2 14.6 9 10 16.4 5.4 9Z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/><path d="M10 9.4v4.4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/><circle cx="10" cy="8.4" r="1.15" fill="currentColor"/></svg>
          </span>
          <span class="app__name">Quire</span>
          <span class="app__sep" aria-hidden="true"></span>
          <span class="app__doc">New message</span>
        </div>
        <span class="ai" data-ai>
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 2.2c.4 2.7 1.4 3.9 4 4.3-2.6.4-3.6 1.6-4 4.3-.4-2.7-1.4-3.9-4-4.3 2.6-.4 3.6-1.6 4-4.3Z" fill="currentColor"/><path d="M12.6 10.6c.15 1 .55 1.45 1.5 1.6-.95.15-1.35.6-1.5 1.6-.15-1-.55-1.45-1.5-1.6.95-.15 1.35-.6 1.5-1.6Z" fill="currentColor"/></svg>
          <span>Suggestions on</span>
        </span>
      </header>

      <div class="fields">
        <p class="field"><span class="field__k">To</span><span class="field__v">Mara Lindqvist</span></p>
        <p class="field"><span class="field__k">Subject</span><span class="field__v">Cover drafts</span></p>
      </div>

      <div class="body" data-body tabindex="0" role="textbox" aria-multiline="true" aria-label="Message body. Tab accepts the suggestion, Escape dismisses it, Control or Command with the right arrow accepts one word.">
        <p class="text" data-text><span data-done></span><span class="caret" data-caret aria-hidden="true"></span><span class="ghost" data-ghost aria-hidden="true"></span></p>
      </div>

      <footer class="editor__foot">
        <p class="status" aria-live="polite"><span class="status__roll" data-status>Draft</span></p>
        <div class="keys" aria-hidden="true">
          <span class="key-hint" data-hint="tab"><kbd class="cap"><span>Tab</span></kbd><span class="key-hint__l">Accept</span></span>
          <span class="key-hint" data-hint="esc"><kbd class="cap"><span>Esc</span></kbd><span class="key-hint__l">Dismiss</span></span>
          <span class="key-hint key-hint--word" data-hint="word"><kbd class="cap cap--wide"><span>Cmd</span><svg viewBox="0 0 12 12"><path d="M2.5 6h7M6.8 3.2 9.6 6 6.8 8.8" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg></kbd><span class="key-hint__l">Word</span></span>
        </div>
      </footer>
    </article>
  </main>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

30 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Ghost text autocomplete” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a warm white page, the Quire card with a new email: at the top the mark, «New message» and the green «Suggestions on» pill, then the recipient and the subject, the body in Newsreader and, at the bottom, the status line with three drawn keys, Tab, Esc and Cmd with the arrow. The text types itself, one letter at a time, with a steady green caret; it stops after the first sentence and, after half a second, the rest appears after the caret in light grey, one word at a time out of a slight blur, with the small Tab key at the end. The Tab key at the bottom is pressed: the grey turns to ink from left to right, a pale green light runs under the words and fades, and the caret jumps to the end with a small bounce. On the second sentence the suggestion is dismissed with Esc and pulls back from its last word to its first; on the third it is taken word by word with Cmd and the arrow, three times, and the rest disappears as soon as typing resumes. The status line rolls: Writing, Suggestion ready, Accepted, Dismissed, Draft saved. When idle, the caret breathes slowly.

How it works

The text and the ghost

The paragraph holds three parts in a row: the written text, the caret and the suggestion. The suggestion’s words are inline-block spans (so they can move and blur) with their leading space kept as text, because a space inside an inline-block at the start of a line would vanish.

The typing

Each letter is added to the last text node and waits with gsap.delayedCall, longer after a comma or a full stop: the rhythm feels like a hand. The caret stays solid while typing and breathes slowly while it waits.

The suggestion

After THINK seconds the words come in with a stagger from opacity 0, 3 pixels to the left and BLUR pixels of blur; the Tab key arrives last with a back.out.

Accepting

The words move from the suggestion into the text, change colour from --ghost to --ink one after another, and a pale bar under each one stretches from the left (--s) and then fades (--o). The caret does a FLIP: it is measured before and after the move and animated from the difference back to zero.

Dismissing and one word at a time

Esc sends the words out from the last to the first, blurring them, and removes them. Cmd or Ctrl with the right arrow takes only the first word left; when typing resumes, the rest disappears at once.

Values to change

NameFileDefaultWhat it changes
TYPE_SPEEDscript.js26How many letters per second while the email types itself.
THINKscript.js0.55The pause before the suggestion appears, in seconds.
WAITscript.js1.5How long a suggestion waits before the demo answers it by itself, in seconds.
SWEEPscript.js0.55How long the pale light takes to run across the accepted words, in seconds.
BLURscript.js4How blurred each suggested word is when it starts to appear, in pixels.
BREATHscript.js1.1How long one breath of the waiting caret lasts, in seconds.
HOLDscript.js2.6How long the finished email stays before it starts again, in seconds.
--accentstyle.css#2f7a5cThe accent: the caret, the pill, the pressed keys.
--ghoststyle.css#b5b0a5The grey of the ghost text.

Try them in the Playground

When to use it

To show an AI writing feature on a product page (an editor, an inbox, a notes app), or as the real state of an editor that suggests: Tab explains itself at a glance.

On phones

The card is sized on the width and the body on the height too (vh); below 460 pixels the key labels and the pill’s text hide and the drawn keys stay. Phones have no Tab key: the demo answers by itself.

With reduced motion

No typing, no blur and no caret jumps: the email is already written up to the last suggestion, which waits in grey; Tab, Esc and Cmd with the arrow accept it or pull it back with a fade.

Pitfalls

  • An inline element cannot be moved or scaled: the suggestion’s words are inline-block, and the space in front stays a text node outside the span, otherwise it would vanish at the start of a line.
  • The jumping caret is measured before and after the words move (FLIP), in the same frame: measuring it after a tween would give the wrong position.
  • The waits are gsap.delayedCall inside Promises, never setTimeout: that way the preview bench also governs the typing rhythm.
  • The real Tab key moves focus off the page: it is stopped with preventDefault only while there is a suggestion.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, Newsreader (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 7.1 KB; the libraries: GSAP 28 KB.

Testing

Tested on 29 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations