Visualforce Typeahead Component

Here is something I hope will be helpful to you.

A few months back, I researched “typeahead” components – controls that let you search for data as you type – for use on Visualforce pages. When you want to provide a lookup to related data on a page, this can provide much better usability than the standard Salesforce lookup control.


The most popular open-source typeahead components appear to be jQueryUI’s autocomplete and typeahead.js from Twitter. I found several helpful examples of the jQueryUI approach, but I wanted to try to the latest version of Twitter typeahead.js instead – primarily because I found it was easier to use with Javascript remoting to query the data rather than the Salesforce REST API. (Using the REST API consumes API calls, which are limited, while remoting does not.)

After I got typeahead.js working on my own page for an internal project, I thought it would be interesting to create a reusable Visualforce component. Introducing visualforce-typeahead, an open-source project you can find and install on Github.

I designed the component with plenty of attributes so that you can customize its behavior, but as they all have default values it is extremely easy to get started with the component – just add it to your page and it works:

<h3>Account Name:</h3>
<c:Typeahead object=”Account” />

I also created a 4-minute video to introduce the component:

You can install the component and resources into your own Salesforce account (or sandbox) using this link.

Please give it a try and leave your feedback, or fork the project on Github.  -ejc