1.0.8 • Published 5 years ago

preact-material-autocompleter v1.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Preact Material Index

A material-design autocompleter with a dropdown. Simple to set up and use along with preact.

You can also find this as an npm package here.

Options

OptionDescriptionRequired
itemsThe list of items that should be displayed to the user in the dropdown. Must be a list of strings.Yes
classNameThe name of the outer-most container classNo
allowAddNewItemsA flag indicating whether or not the user is allowed to add itemsNo
hintTextA string describing what the user is choosingNo
idThe id of the underlying TextFieldNo
onChangeA callback function that is called when the user selects a value from the dropdownNo

Examples

Example 1

Render the autocompleter with three items; 'one', 'two' and 'three' and without the possibility to add options.

autocompleter without 'allowAddNewItems' option enabled

import AutoCompleter from 'preact-material-autocompleter';

export default class App extends Component {

	render() {
		return (
			<div id="app" >
				<AutoCompleter items={['one', 'two', 'three']}
							   onChange={e => console.log('You selected ' + e.target.value)} hintText="Select an item"
				/>
			</div>
		);
	}
}

Example 2

Render the autocompleter with three items; 'one', 'two' and 'three' and allow users to add items.

autocompleter with 'allowAddNewItems' option enabled

import AutoCompleter from 'preact-material-autocompleter';

export default class App extends Component {

	render() {
		return (
			<div id="app" >
				<AutoCompleter items={['one', 'two', 'three']}
							   onChange={e => console.log('You selected' + e.target.value)} hintText="Select an item"
							   allowAddNewItems
				/>
			</div>
		);
	}
}
1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago