For AI agents: a documentation index is available at /llms.txt, and the full corpus at /llms-full.txt. A markdown version of any page on this site is available by appending .md to its URL path — the homepage is at /index.md.

API Reference

Every prop, hook, and type — distilled.

<AIAutocomplete />

The full drop-in component. Owns the input, dropdown, and pills.

PropTypeDefaultDescription
onSubmitRequired(result: AutocompleteResult) => voidCalled on Enter or submit. Receives an AutocompleteResult.
onError(error: Error) => voidCalled when a fetch fails.
apiConfigAPIConfigRuntime API configuration (key or token).
additionalContextRecord<string, unknown>Optional user context. Include whatever you know about the user (a profile, preferences, workspace, anything) to personalize suggested parameters and options to them.
classNamestringClass applied to the container.
columnsnumber2Number of columns in the dropdown grid.
pillPlacement"inline" | "dropdown" | "hidden""dropdown"Where unfilled pills render. inline lives in the input; dropdown places them with options.
mode"light" | "dark" | "auto""auto"Color mode. auto follows prefers-color-scheme.
optionsPosition"above" | "below""below"Where the dropdown opens relative to the input.
animationsbooleantrueEnable selection streak + new-param shimmer.
dropdownTrigger"auto" | "manual" | "hidden""auto"When the dropdown appears. auto = when options available; manual = only on pill tap.
closeDropdownOnBlurbooleantrueWhen false, the dropdown stays open even when the input loses focus.
showNonTappableOptionsbooleantrueWhen false, options the server marked is_tappable: false (hint rows like "or type something else…") are hidden instead of rendered alongside the selectable ones.
submitButtonReactNode | nullCustom submit button. Pass any node to replace the built-in arrow button, or null to render none. Leaving it undefined keeps the default. The library wraps your node so clicks bubble up and trigger submit.
autoFocusbooleantrueFocus the input on mount. Set to false to leave focus to the consumer.
onFocus() => voidCalled when the input gains focus.
onBlur() => voidCalled when the input loses focus.
maskCompletedTextbooleanfalseStrip completed-param text from network requests (PII masking).
optionOverridesRecord<string, (query) => SuggestionOption[]>Override option lists per suggestion type.
valuestringControlled text value.
completedParamsCompletedParamState[]Controlled completed params.
onChange(value: string) => voidCalled when text changes (controlled mode).
onParamsChange(params: CompletedParamState[]) => voidCalled when params change (controlled mode).
productsProductsConfigOpt-in product strip. When set, the dropdown renders a row of product cards below the options grid, fed by your own search endpoint on the SDK's existing fetch cadence. The object may be re-created on every render — only toggling the strip on or off reaches the core, so swapping one live config for another leaves the current cards up until the next request.
onProductSelect(product: Product) => voidCalled when the user activates a product card. The SDK does not navigate — you decide what a selection means. Modifier and middle clicks are left to the browser (so cmd-click still opens a tab) and don't fire this.
refRef<AIAutocompleteHandle>Imperative handle: focus(), blur(), reset(), setMode().

useAIAutocomplete()

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

PropTypeDescription
completedParamsCompletedParamState[]Filled parameters.
skippedParamsSkippedParamState[]Suggestions the user dismissed with the skip key (→). Nothing renders them — pass them to buildSubmitResult (or read them for your own telemetry) so a hand-rolled submit carries the same text: "skipped" entries the SDK's own requests do.
suggestionPillsSuggestion[]Unfilled suggestions (pills). First item is the active pill.
segmentsSegment[]Input text split into typed text vs completed segments.
newParamIdstring | nullID of the most recently added param (for shimmer).
suggestionsSuggestion[]All suggestions from server (including placeholder type).
activeIndexnumberHighlighted option index. -1 = none.
isLoadingbooleanFetch in progress.
isReadybooleanServer indicates query is complete.
isDropdownOpenbooleanWhether the dropdown should be visible. Drive your own dropdown's visibility with this in Tier 3.
isFocusedbooleanWhether the input currently has focus, as last reported through inputProps or setFocused().
isActivePillSelectedbooleanWhether the leading pill should render selected (full opacity) rather than de-emphasized. True while a tappable dropdown option is highlighted; in "manual" trigger mode, true once the pill has been tapped.
productsProduct[]Results of the latest product search. Empty unless the products option is configured, and already spread into dropdownProps — read it directly only when you render your own strip.
listboxIdstringGenerated id shared by the input's aria-controls and your dropdown's listbox element. Use it when you render your own dropdown so the combobox stays correctly wired for screen readers.
placeholderTextstringSuggested placeholder text for the current step.
errorError | nullLast fetch error.

Input forwarding (custom inputs)

PropTypeDescription
handleTextChange(text: string) => voidForward the input's current plain text to the engine on every edit. Custom inputs only — textareas use inputProps.
handleKeyDown(e: KeyboardEvent) => voidForward 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) => voidTell the engine the input gained or lost focus. Custom inputs only.
handleCaretMove(offset: number) => voidReport the caret position (plain-text offset) so arrow keys can move into the dropdown. Call on selection changes. Custom inputs only.

Actions

PropTypeDescription
setActivePill(index: number) => voidMove the pill at index to front (active).
removeLastParam() => voidRemove last completed param, restore as a pill.
clearNewParamId() => voidClear shimmer animation state.
reset() => voidClear all state, re-fetch.
selectProduct(product: Product) => voidAnnounce a product-card activation, firing onProductSelect. The built-in dropdown calls this for you; hand-rolled strips call it themselves. The SDK never navigates.

Spread props

PropTypeDescription
inputPropsTextareaHTMLAttributesSpread onto a <textarea>. Includes value, placeholder, onChange, onKeyDown, and ARIA attributes.
dropdownPropsAIAutocompleteDropdownPropsSpread 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.

PropTypeDescription
valuestringCurrent input text — render it as the textarea's value.
placeholderstring | undefinedSuggested placeholder for the active step (may be undefined).
onChange(e: ChangeEvent<HTMLTextAreaElement>) => voidForwards edits to the engine (also handles autocapitalize).
onKeyDown(e: KeyboardEvent<HTMLTextAreaElement>) => voidRoutes Arrow / Enter / Tab / Escape to the dropdown while it's open.
onFocus / onBlur() => voidNotify the engine when the input gains or loses focus.
role + aria-*ARIA attributesCombobox accessibility wiring: role="combobox", aria-expanded, aria-activedescendant, aria-autocomplete, aria-controls.

<AIAutocompleteDropdown />

Spread dropdownProps from useAIAutocomplete.

PropTypeDefaultDescription
suggestionsRequiredSuggestion[]Suggestions to display.
activeIndexRequirednumberHighlighted option index.
onSelectRequired(option: SuggestionOption) => voidCalled when an option is selected.
onHighlightRequired(index: number) => voidCalled on mouse hover.
isOpenRequiredbooleanWhether the dropdown is visible.
idRequiredstringListbox ID for ARIA.
pillsSuggestion[]Pills to render inside the dropdown.
onPillClick(index: number) => voidCalled when a pill is clicked.
showPillsbooleantrueWhether to render pills.
optionsPosition"above" | "below""below"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.
classNamestringCSS class applied to the dropdown.

AutocompleteResult

The shape of the object passed to onSubmit.

PropTypeDescription
querystringPlain text as the user sees it.
raw_querystringText with placeholder tokens (e.g. "Create a {{TASK_1}}").
completed_paramsCompletedParam[]Filled parameter values.