horsey.js Demos

Progressive and customizable autocomplete component

Fork me on GitHub
      
horsey(document.querySelector('input'), {
  suggestions: ['banana', 'apple', 'orange']
});
      
    
Being lazy...
      
horsey(document.querySelector('input'), {
  suggestions: function (done) {
    setTimeout(function () {
      done(['banana', 'apple', 'orange']);
    }, 2000);
  }
});
      
    
      
horsey(document.querySelector('input'), {
  suggestions: [
    { value: 'banana', text: 'Bananas from Amazon Rainforest' },
    { value: 'apple', text: 'Red apples from New Zealand' },
    { value: 'orange', text: 'Oranges from Moscow' },
    { value: 'lemon', text: 'Juicy lemons from Amalfitan Coast' }
  ]
});
      
    
      
horsey(document.querySelector('input'), {
  suggestions: [
    { value: 'banana', text: 'Bananas from Amazon Rainforest' },
    { value: 'apple', text: 'Red apples from New Zealand' },
    { value: 'orange', text: 'Oranges from Moscow' },
    { value: 'lemon', text: 'Juicy lemons from Amalfitan Coast' }
  ],
  render: function (li, suggestion) {
    var image = '<img class="autofruit" src="example/fruits/' + suggestion.value + '.png" /> ';
    li.innerHTML = image + suggestion.text;
  }
});
      
    
      
horsey(document.querySelector('input'), {
  suggestions: [
    { value: 'banana', text: 'Bananas from Amazon Rainforest' },
    { value: 'banana-boat', text: 'Banana Boat' },
    { value: 'apple', text: 'Red apples from New Zealand' },
    { value: 'apple-cider', text: 'Red apple cider beer' },
    { value: 'orange', text: 'Oranges from Moscow' },
    { value: 'orange-vodka', text: 'Classic orange vodka cocktail' },
    { value: 'lemon', text: 'Juicy lemons from Amalfitan Coast' }
  ],
  limit: 2
});
      
    
      
horsey(document.querySelector('textarea'), {
  suggestions: [
    { value: '@michael', text: 'Michael Jackson' },
    { value: '@jack', text: 'Jack Johnson' },
    { value: '@ozzy', text: 'Ozzy Osbourne' }
  ],
  anchor: '@'
});
      
    
Click here to set fruity treat type
      
horsey(document.querySelector('div'), {
  suggestions: [
    { value: 'banana', text: 'Bananas from Amazon Rainforest' },
    { value: 'banana-boat', text: 'Banana Boat' },
    { value: 'apple', text: 'Red apples from New Zealand' },
    { value: 'apple-cider', text: 'Red apple cider beer' },
    { value: 'orange', text: 'Oranges from Moscow' },
    { value: 'orange-vodka', text: 'Classic orange vodka cocktail' },
    { value: 'lemon', text: 'Juicy lemons from Amalfitan Coast' }
  ]
});
      
    

Get it on GitHub! bevacqua/horsey