Use the hook for custom rendering. Same options as <AIAutocomplete /> minus the rendering-only props (className, mode, optionsPosition, animations, pillPlacement, autoFocus). The hook doesn't own the textarea — onFocus and onBlur fire when the consumer-owned textarea's focus changes.
State
Prop
Type
Default
Description
completedParams
CompletedParamState[]
—
Filled parameters.
suggestionPills
Suggestion[]
—
Unfilled suggestions (pills). First item is the active pill.
segments
Segment[]
—
Input text split into typed text vs completed segments.
newParamId
string | null
—
ID of the most recently added param (for shimmer).
suggestions
Suggestion[]
—
All suggestions from server (including placeholder type).
activeIndex
number
—
Highlighted option index. -1 = none.
isLoading
boolean
—
Fetch in progress.
isReady
boolean
—
Server indicates query is complete.
isDropdownOpen
boolean
—
Whether the dropdown should be visible. Drive your own dropdown's visibility with this in Tier 3.
placeholderText
string
—
Suggested placeholder text for the current step.
error
Error | null
—
Last fetch error.
Input forwarding (custom inputs)
Prop
Type
Default
Description
handleTextChange
(text: string) => void
—
Forward the input's current plain text to the engine on every edit. Custom inputs only — textareas use inputProps.
handleKeyDown
(e: KeyboardEvent) => void
—
Forward a keyboard event so the engine can handle Arrow/Enter/Tab/Escape while the dropdown is open. Check event.defaultPrevented to see if it was consumed. Custom inputs only.
setFocused
(focused: boolean) => void
—
Tell the engine the input gained or lost focus. Custom inputs only.
handleCaretMove
(offset: number) => void
—
Report the caret position (plain-text offset) so arrow keys can move into the dropdown. Call on selection changes. Custom inputs only.
Actions
Prop
Type
Default
Description
setActivePill
(index: number) => void
—
Move the pill at index to front (active).
removeLastParam
() => void
—
Remove last completed param, restore as a pill.
clearNewParamId
() => void
—
Clear shimmer animation state.
reset
() => void
—
Clear all state, re-fetch.
Spread props
Prop
Type
Default
Description
inputProps
TextareaHTMLAttributes
—
Spread onto a <textarea>. Includes value, placeholder, onChange, onKeyDown, and ARIA attributes.
dropdownProps
AIAutocompleteDropdownProps
—
Spread onto <AIAutocompleteDropdown />. Its shape is exactly the <AIAutocompleteDropdown /> props documented below — in Tier 3, read suggestions, activeIndex, isOpen, onSelect, and onHighlight from it to render your own dropdown.
inputProps fields
What inputProps contains, for when you want to add a handler or wire a non-textarea input. Spread it onto a <textarea>; for a contentEditable or rich-text input, skip it and use the input-forwarding actions above.
Prop
Type
Default
Description
value
string
—
Current input text — render it as the textarea's value.
placeholder
string | undefined
—
Suggested placeholder for the active step (may be undefined).
onChange
(e: ChangeEvent<HTMLTextAreaElement>) => void
—
Forwards edits to the engine (also handles autocapitalize).
onKeyDown
(e: KeyboardEvent<HTMLTextAreaElement>) => void
—
Routes Arrow / Enter / Tab / Escape to the dropdown while it's open.
onFocus / onBlur
() => void
—
Notify the engine when the input gains or loses focus.
Where the dropdown opens relative to the input — "above" or "below". Default "below".
mode
"light" | "dark" | "auto"
—
Color mode for a standalone dropdown — self-scopes the SDK tokens so no .magicx-aia wrapper is needed. Leave unset when nested inside a .magicx-aia ancestor.
className
string
—
CSS class applied to the dropdown.
AutocompleteResult
The shape of the object passed to onSubmit.
Prop
Type
Default
Description
query
string
—
Plain text as the user sees it.
raw_query
string
—
Text with placeholder tokens (e.g. "Create a {{TASK_1}}").