# Typeahead

# Demo

<typeahead
  initial-id="14"
  initial-value="John Stockton"
  id="typeahead-input"
  placeholder="Type a name"
  :initial-items="[
    { id: 12, value: 'John Cleese' },
    { id: 13, value: 'John Malkovich' },
    { id: 14, value: 'John Stockton' }
  ]"
  hidden-input-name="typeaheadId"
/>

# Props

initial-items

Type
Array

Description
An array of items that will be used to display autocomplete suggestions ([{ id: 1, value: 'hey' }])
initial-value

Type
String

Description
Initial value of the autocomplete suggestion
initial-id

Type
String

Description
Initial id of the autocomplete suggestion
src

Type
String

Description
URL that will be used to fetch autocomplete suggestions (such as: /user/search?q=). A query will be appended to this URL. There is no need to define initial-items when a remote source is defined.
id

Type
String

Description
The id attribute of the input element
placeholder

Type
String

Description
The placeholder attribute of the input element
limit

Type
Number

Default
0

Description
Limit the number of autocomplete suggestions, no limit is applied by default
name

Type
String

Description
The name of the input field
hidden-input-name

Type
String

Description
The name of a hidden input field that will be populated with autocomplete suggestion's id

# Events

selected

Parameters
Item (Object)

Description
Emitted when an item gets selected
error

Parameters
Response (Object)

Description
Emitted when an error occurs while sending a request to the remote source