Skip to content

GhostText

Stable

Faded suggested text that appears after what you typed, with a Tab key hint.

Also known as inline completion, autocomplete text, copilot suggestion

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Accept or dismiss

Thanks for the update.Suggestion available: I will review the draft tomorrow morning.. Press Tab to accept, Esc to dismiss. Ctrl + Right accepts one word.

Click the Tab hint to accept, or the close button to dismiss. In a real editor, Tab accepts and Escape dismisses.

When to use it

A suggested ending shown faded after what someone typed, with a hint for the key that accepts it. It looks clearly different from real text and only becomes text when accepted.

Made of: Typed text · Suggestion · Key hint to accept · Hint to accept one word · Dismiss button · Hidden description for screen readers

Use it for

  • Completing the sentence or line someone is typing.
  • Offering a long suggestion that can be accepted a word at a time, with a hint that says how.

Not for

Do and avoid

Let's meet at theSuggestion available: station at 9. Press Tab to accept, Esc to dismiss.

Do. A short faded ending that is easy to take or ignore.

Let's meet at theSuggestion available: station at 9, then walk to the market, have lunch by the river, visit the old castle and take the late train home together.. Press Tab to accept, Esc to dismiss.

Avoid. A whole faded paragraph is hard to read and hard to judge.

Do

  • Make Tab, or your accept key, work from the keyboard as well as from the hint.
  • Dismiss on Escape, and when the person keeps typing.
  • For long suggestions, let people accept one word at a time and say how.
  • Keep the suggestion looking different from real text.

Avoid

  • Do not put the suggestion into the real text before it is accepted.
  • Do not make screen readers announce the suggestion. It changes with every key press.
  • Do not use it for whole paragraphs. Use SuggestionBar.

On a phone

  • Phones have no Tab or Esc key, so pass onAccept and onDismiss. The key hint then becomes a tap target and a dismiss button appears.
  • On touch screens both buttons keep their size and have a 44px tap area, so the line they sit in does not get taller.
  • The hint shows the accept key as text, so set acceptKey to something a phone user understands or hide the hint.

Seen in products

  • GitHub Copilot in VS Code and Visual Studio shows dimmed ghost text that completes the current line or a block, accepted with Tab.
  • With Next Edit Suggestions, Tab navigates to the suggested edit and Tab again accepts it.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started