Ghost textPro
Inline AI autocomplete: muted ghost text continues your sentence at the caret, Tab turns it solid in place, ⌘→ takes a word, Esc fades it away, and a chip names the model.
oxyn add ghost-textThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
Rendered from Rust at build time · goes live when visible
When to use
- Inline AI autocomplete.
- After delay_ms (450) of pause and at least min_len (3) trimmed characters, the model is asked for a continuation of the text; it shows muted right after the text, fading in (140 ms).
- Typing that matches the ghost consumes it in place; any other edit clears it and a new ask follows the next pause.
- Tab accepts all of it, ⌘/Ctrl/Alt+→ accepts one word (the rest stays), Escape dismisses it (with nothing showing Escape is left to the page); moving the caret away (←, ↑, Home, a click) or leaving the field clears it.
When not to use
- On or off for things that apply right away: use Switch instead.
- A real checkbox with a label and second line, an indeterminate state for Select all, an error, a card row and a check that draws itself: use Checkbox instead.
- Pick one: use Radio group instead.
Installation
Ghost text is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.
oxyn add ghost-textUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Field
A suggestion waits after the text: Tab takes it.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Single
Single line with the chip inline at its end.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Plain
Plain: flush inside a card of your own.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Offline
The chip says No suggestion.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
GhostText
| Prop | Type | Default | Description |
|---|---|---|---|
value | String | Default::default() | Starting text. |
placeholder | Option<String> | Default::default() | Placeholder. |
label | Option<String> | Default::default() | Quiet label row above the text (multi-line only). |
model | String | "Autocomplete" | Model named in the chip. |
multiline | bool | true | Growing textarea with a footer row, or a single line with the chip at its end. |
variant | String | "field" | `field` (own border and ring) · `plain` (sits flush in a card). |
rows | usize | 3 | Minimum lines. |
hint | bool | true | Show the chip and key hints. |
offline | bool | Default::default() | The model fails every ask (demos the error chip). |
delay_ms | u64 | 450 | Pause before asking, ms. |
latency_ms | u64 | 380 | Simulated model latency, ms. |
disabled | bool | Default::default() | Disabled. |
nowrequired | ClockMs | — | Shared clock. |
on_accept | EventHandler<(String, &'static str)> | — | Accepted text, with "all" or "word". |
on_input | EventHandler<String> | — | Every edit. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Accepts the whole suggestion (moves focus when none shows) |
| ⌘/Ctrl/Alt→ | Accepts the next word |
| Esc | Dismisses the suggestion (left to the page when none shows) |
| Typing | Matching characters consume the ghost; others clear it |
| ← ↑ Homeorclick | Moving the caret away clears it |
Accessibility
- The ghost is drawn in an aria-hidden mirror; the field keeps its own text.
- aria-describedby explains the keys; the chip is a polite live region.
- Reduced motion drops the fade and the accept ease.
From the spec
- The ghost is drawn in an aria-hidden mirror under a transparent-text field, so the field's own value is what assistive tech reads.
- aria-describedby explains the keys; the chip is a polite live region.
Motion & interaction
Timing
- Reduced motion: rows open at full height, words and digits swap without rise or roll, the ghost appears and turns solid without fading, the height tween is off.
Responsive behaviour
- Key hints hide on narrow fields; the chip stays.
Edge cases (spec)
- Key hints hide below 420 px of container width; the chip stays.
Notes for AI
- Import
GhostTextfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - There is no GPUI version yet; use the Dioxus component.
- Props to set first:
now. - It reads a clock (
now) for live timers; pass one clock for the whole page rather than one per component. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.