Typeahead

March 30, 2026 · View on GitHub

Text input with inline ghost-text suggestion. Extends Input — all Input methods and events apply.

Constructor: NewTypeahead(id, class string, params ...string) *Typeahead

params follow the same convention as NewInput: optional initial value and placeholder.

Methods

  • SetSuggest(fn func(string) []string) — sets the suggestion provider; called on every keystroke with the current text; the first returned string becomes the ghost-text suggestion

All other methods are inherited from Input.

Events

EventDataDescription
"accept"stringSuggestion accepted; data is the completed text
"change"stringText changed (inherited from Input)

Notes

Flags: "focusable", "masked", "readonly"

Tab or (when cursor is at end) accepts the active suggestion and dispatches "accept". Esc clears the suggestion without accepting.

Style selectors: "typeahead", "typeahead/suggestion" — with :focused state.