API Reference

Every constructor option, instance method, state field, and event — for the framework-agnostic SDK.

Constructor options

Pass these to the constructor as the second argument.

PropTypeDefaultDescription
renderMode"full" | "dropdown" | "headless""full"Tier — full owns everything; dropdown lets you own the input; headless gives you state only.
apiConfigRequiredAPIConfigRuntime API configuration (key or token).
placeholderstringFallback placeholder when the server doesn't return one.
columnsnumber2Number of columns in the dropdown grid.
mode"light" | "dark" | "auto""auto"Color mode. auto follows prefers-color-scheme.
optionsPosition"above" | "below""below"Where the dropdown opens.
animationsbooleantrueEnable selection streak + shimmer animations.
pillPlacement"inline" | "dropdown" | "hidden""inline"Where unfilled pills render.
dropdownTrigger"auto" | "manual" | "hidden""auto"When the dropdown appears.
closeDropdownOnBlurbooleantrueWhen false, the dropdown stays open even when the input loses focus.
autoFocusbooleantrueFocus the input on mount (Tier 1 only).
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.
onSubmit(result) => voidCalled on Enter or submit.
onError(error) => voidCalled when a fetch fails.
onChange(text: string) => voidCalled when text changes.
onParamsChange(params) => voidCalled when params change.

Instance methods

Methods are available on the instance after construction. Tier 3 (headless) leans heaviest on these.

PropTypeDefaultDescription
focus()() => voidFocus the input.
blur()() => voidBlur the input (Tier 1 only).
reset()() => voidClear all state, re-fetch.
destroy()() => voidCleanup — abort fetches, clear timers, remove listeners.
setMode(mode)(mode: "light" | "dark" | "auto") => voidSwitch color mode at runtime.
setValue(text)(text: string) => voidSet text (controlled mode).
setCompletedParams(params)(params) => voidSet completed params (controlled mode).
update(opts)(opts: Partial<Options>) => voidUpdate multiple options at once (e.g. animations, pillPlacement).
handleTextChange(text)(text: string) => voidCall when the user types. Handles capitalization, param reconciliation, filter updates.
handleKeyDown(event)(event: KeyboardEvent) => voidForward keyboard events. Handles arrow nav, Enter, Tab, Escape.
setFocused(focused)(focused: boolean) => voidNotify the library that the input has focus. Required for dropdownTrigger "auto" in Tier 2/3 — the dropdown only opens while focused.
selectOption(option)(option: SuggestionOption) => voidSelect a dropdown option. Updates text, creates completed param, triggers shimmer.
setActiveDropdownIndex(index)(index: number) => voidSet the highlighted option (e.g. for mouse hover).
setActivePill(index)(index: number) => voidMove the pill at index to the front (active).
removeLastParam()() => voidRemove last completed param, restore as a pill.
clearNewParamId()() => voidClear shimmer animation state.
getState()() => CoreStateGet a snapshot of the current state.
subscribe(listener)(listener) => () => voidSubscribe to state changes (fires after derived state settles). Returns an unsubscribe function.
on(event, handler)(event, handler) => () => voidSubscribe to a specific event. Returns an unsubscribe function.

State (CoreState)

Snapshot of the SDK's reactive state. Read it via getState() or via subscribe(state => ...).

PropTypeDefaultDescription
textstringCurrent input text.
completedParamsCompletedParamState[]Filled parameters.
suggestionsSuggestion[]All suggestions from server (including placeholder type).
actionableSuggestionsSuggestion[]Non-placeholder suggestions (the pills).
filteredOptionsSuggestionOption[]Options for the active suggestion, filtered by the current query.
segmentsSegment[]Input text split into typed text vs completed params — for overlay rendering.
placeholderTextstringResolved placeholder text (from server or option).
activeDropdownIndexnumberHighlighted option index. -1 = none.
isDropdownOpenbooleanWhether the dropdown should be visible.
newParamIdstring | nullID of the most recently added param (for shimmer).
isLoadingbooleanFetch in progress.
isReadybooleanServer indicates the query is complete.
errorError | nullLast fetch error.

Events

Subscribe to specific events with on(). The returned function unsubscribes.

events.ts
const off = ac.on("submit", (result) => console.log(result));
off(); // unsubscribe
// Available events: "submit" | "error" | "change" | "paramsChange" | "focus" | "blur"