0.5.2 • Published 1 year ago

@mkyy/mui-search-bar v0.5.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

mui-search-bar

npm.io

GitHub npm coffee

Installation

npm i --save @mkyy/mui-search-bar

or

yarn add @mkyy/mui-search-bar

Note: This component is intended to projects using Material-UI v5+, if you're still using an older version, I recommend material-ui-search-bar.

Usage

The SearchBar is a controlled input, meaning that you need to keep the input state. This allows for much flexibility, e.g. you can change and clear the search input just by changing its props.

import SearchBar from '@mkyy/mui-search-bar';

return (
  <SearchBar
    value={textFieldValue}
    onChange={newValue => setTextFieldValue(newValue)}
    onSearch={handleSearch}
  />
);

!Important: If you are using options to auto-complete suggests, you need to get the value of the clicked option inside your handleSearch function.

If you try using your controlled input state to manage this event, you'll get the old value, and not the labelOptionValue.

import SearchBar from '@mkyy/mui-search-bar';

const handleSearch = labelOptionValue => {
  //...
  console.log(labelOptionValue);
};

return (
  <SearchBar
    value={textFieldValue}
    onChange={newValue => setTextFieldValue(newValue)}
    onSearch={handleSearch}
  />
);

SearchBar Properties

NameTypeDefaultDescription
classNamestring''Custom top-level class.
widthstring or number'300px'Sets the width of SearchBar.
heightstring or number'40px'Sets the height of SearchBar.
disabledboolfalseDisables text field.
onCancelResearchfuncFired when the search is cancelled.
onChangefuncFired when the text value changes.
onSearchfuncFired when enter button is pressed.
placeholderstring'Search'Sets placeholder text for the embedded text field.
styleobjectnullOverride the inline-styles of the root element.
valuestring''The value of the text field.
optionsArray<string>[]Options of autocomplete suggests list.

* required properties

License

The files included in this repository are licensed under the MIT license.

Contributions

Feel free to open an issue or add a pull request. Anytime. Really, I mean it.

Also, if you like my work, I'll let you know that I love coffee.

0.5.2

1 year ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.8

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago