ValyroUI Русская версия

Inline Suggestion

Inline autocomplete suggestion. Pro · AI chat and agents › Prompts and models

Copilot-style ghost text for a textarea or input: a completion fetched as you pause typing appears after the caret. Tab accepts it, Ctrl/⌘ → accepts a word, Escape dismisses. className and style go to the field wrapper, other props to the native control.

Installation

npx valyro-cli@latest login
npx valyro-cli@latest add inline-suggestion
npm install valyro-ui-pro

import 'valyro-ui-pro/styles.css';
import { InlineSuggestion } from 'valyro-ui-pro';

Props

PropTypeDefault
valuestringControlled value; use with onValueChange.
defaultValuestring''Initial value when uncontrolled.
onValueChange(value: string) => voidCalled with the new value when it changes.
getSuggestion *(text: string, request: InlineSuggestionRequest) => Promise<string | null | undefined> | string | null | undefinedReturns the completion for text (what follows the caret), or nothing. Called after the user pauses typing with the caret at the end; may be async. Errors go to onError.
debouncenumber350Pause in typing before asking, in ms.
minLengthnumber3Minimum text length before asking.
multilinebooleantrueA textarea (default) or a single-line input.
showHintbooleantrueShow the Tab key hint next to a suggestion.
defaultSuggestionstringA suggestion shown from the first render, before focus: a static preview, or a completion the app already has for defaultValue. It stays until the field loses focus, is edited or dismissed; Tab and Ctrl/⌘ → accept it like a fetched one.
onAccept(accepted: string, kind: 'all' | 'word') => voidCalled with the accepted text: all of it (Tab) or one word (Ctrl/⌘ →).
onError(error: unknown) => voidA failed getSuggestion. Without it the error is logged to the console.
refRef<HTMLTextAreaElement | HTMLInputElement>The text field: the <textarea>, or the <input> when multiline is off.
labelsPartial<InlineSuggestionLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

Previous: Prompt Composer · Next: Model Selector · All AI chat and agents