surmiser
A lightweight autocomplete engine for the web.
Vanilla JS
Add smart autocomplete to any input in 3 lines
import { attachSurmiser } from 'surmiser';
const phraseInput = document.getElementById('phrase-input');
attachSurmiser(phraseInput);
import { attachSurmiser } from 'surmiser';
const phraseInput = document.getElementById('phrase-input');
attachSurmiser(phraseInput); Custom Vanilla JS
Add custom corpus to any input in 3 lines
import { attachSurmiser } from 'surmiser';
const phraseInput = document.getElementById('phrase-input');
const commonPhrases = ['Hello there', 'Good morning'...];
attachSurmiser(phraseInput, {
corpus: commonPhrases,
});
import { attachSurmiser } from 'surmiser';
const phraseInput = document.getElementById('phrase-input');
const commonPhrases = ['Hello there', 'Good morning'...];
attachSurmiser(phraseInput, {
corpus: commonPhrases,
}); React
Drop-in component for quick usage
import { SurmiserInput } from 'surmiser/react';
const MyComponent = () => (
<SurmiserInput
placeholder="Type here..."
/>
);
import { SurmiserInput } from 'surmiser/react';
const MyComponent = () => (
<SurmiserInput
placeholder="Type here..."
/>
); React Hook
Full control with the useSurmiser hook
import { useSurmiser } from 'surmiser/react';
const corpus = ['Hello world', 'React is great'];
const MyComponent = () => {
const { attachRef } = useSurmiser({
corpus
});
return <input ref={attachRef} />;
};
import { useSurmiser } from 'surmiser/react';
const corpus = ['Hello world', 'React is great'];
const MyComponent = () => {
const { attachRef } = useSurmiser({
corpus
});
return <input ref={attachRef} />;
};