Pattern 39 · Output

Inline AI suggestions in documents and forms

A chat window pulls people out of the document, and a rewrite of the whole paragraph is too much to accept or reject at once.

By Alex StepikinUpdated December 20264 min readLive demo
In short

Show the suggestion as muted ghost text after the cursor, never inserted until a key is pressed. Provide one key for accepting all, one for the next word and one for dismissing it. For longer suggestions in forms, split them into chunks that are accepted or rejected one by one. Appear after a pause and stay silent when unsure.

Live demo · try it

An interactive mock built in plain HTML, CSS and JavaScript. Data is fictional; no model is called.

FitWhen to use it — and when not

Use it when

  • Writing and coding surfaces where the next few words are predictable
  • Forms with free-text fields people fill repeatedly (reasons, descriptions, replies)
  • Anywhere the user’s attention is in the text, not in a chat panel

Skip it when

  • Tasks that need a reasoned answer or a whole new draft: use a chat or a diff
  • Fields where a wrong suggestion has real cost and little context exists to predict it
  • Short inputs such as names, numbers and codes

AnatomyThe parts of the pattern

  1. Ghost textThe suggestion in a muted style after the cursor, never in the text itself.
  2. Accept keysOne key for the whole suggestion, one for the next word, one to dismiss.
  3. ChunksFor longer suggestions, separate pieces the user accepts or rejects one by one.
  4. Trigger ruleWhen suggestions appear: after a pause, at line end, not mid-word.
  5. Quiet modeA setting to turn them off per field, document or entirely.
  6. Feedback signalAccepted, edited-after-accept and dismissed are logged as separate events.

GuidelinesDo & don’t

Do

  • Show a suggestion only when it is likely to be accepted; silence is a feature.
  • Allow word-by-word acceptance so a mostly-right suggestion is still useful.
  • Keep the suggestion visually distinct and never move the text under the cursor.
  • Match the user’s language, tone and terminology from the document.

Don’t

  • Show a suggestion on every keystroke.
  • Insert text without a keypress.
  • Cover the text the user is typing, or shift the layout when a suggestion appears.
  • Reuse the same suggestion after it was dismissed.

In the wildReal-world examples

GitHub Copilot (ghost text, accept by word)Gmail (Smart Compose)Grammarly (inline suggestions)Notion AI

Products named for reference only — no affiliation, and the demo above is an original illustration, not a copy of their UI.

For engineersImplementation notes

  • Debounce on typing pause, cancel the request on the next keystroke and drop stale responses.
  • Keep latency under about 300 ms; a late suggestion is worse than none, so discard it if the cursor moved.
  • Send only the nearby text and field label as context; do not stream the whole document per keystroke.
  • Log shown, accepted in full, accepted in part, edited after and dismissed, to tune the trigger rule.

Q&ACommon questions

How is inline AI different from accept and reject edits?

Inline suggestions are small, continue what the user is writing and appear at the cursor. Accept and reject edits show a diff of a rewrite the user asked for. Use ghost text to speed typing and a diff to review changes to existing text.

When should AI autocomplete show a suggestion?

After a short pause, at a natural boundary such as the end of a line or sentence, and only when the model is likely to be right. Showing something on every keystroke distracts, and a late suggestion should be discarded.

How do you measure whether inline suggestions help?

Track shown, accepted in full, accepted in part, edited after accepting and dismissed. A high rate of edits after accepting means the suggestion was close but not good enough, which is a different problem from low acceptance.

See alsoRelated patterns

All 40 LLM UX patterns

Does this pattern work in your product?

The AI Trust Audit checks how your product handles this pattern and the other moments where people decide whether to trust the AI. You get 10+ fixes ranked by impact and effort, and your key flow redesigned. 5 working days, $990, credited to a build if we continue. Related case: Atlas, a control room for a fleet of AI agents.

Get the audit · $990Ask a question first

Create bold.
Deliver better.

See our workGet in touch