# react-search-bar-semantic-ui

> This is a search bar component with built-in searching functions and make use of Semantic UI React for UI.

Latest version **1.1.1** (published 2019-05-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-search-bar-semantic-ui
pnpm add react-search-bar-semantic-ui
yarn add react-search-bar-semantic-ui
bun add react-search-bar-semantic-ui
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-05-07 |
| First published | 2019-05-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Boyi Yao |
| Maintainers | eric1015 |
| Keywords | react, react-component, search, search-bar, semantic-ui |

## Links

- npm: https://www.npmjs.com/package/react-search-bar-semantic-ui
- Repository: https://github.com/Eric1015/react-search-bar-semantic-ui
- Homepage: https://github.com/Eric1015/react-search-bar-semantic-ui#readme
- Issues: https://github.com/Eric1015/react-search-bar-semantic-ui/issues
- npm.io page: https://npm.io/package/react-search-bar-semantic-ui

## Dependencies (6)

- [react](https://npm.io/package/react.md) ^16.8.6
- [webpack](https://npm.io/package/webpack.md) ^2.6.1
- [react-dom](https://npm.io/package/react-dom.md) ^16.8.6
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [semantic-ui-css](https://npm.io/package/semantic-ui-css.md) ^2.4.1
- [semantic-ui-react](https://npm.io/package/semantic-ui-react.md) ^0.86.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-05-07
- 1.1.0 — 2019-05-07
- 1.0.1 — 2019-05-06
- 0.0.1 — 2019-05-05

## README

# React Search Bar Semantic UI

A search bar component built based on Semantic UI React.

日本語版は[こちら](docs/README_jp.md)

### Installation

```shell
npm install --save react-search-bar-semantic-ui
```

For [CommonJS](http://wiki.commonjs.org/wiki/CommonJS) user:

```javascript
import SearchBar from 'react-search-bar-semantic-ui';
```

### Usage

The following code is the basic usage of <code>SearchBar</code> component by assigning all the fields used in default search result component.

```javascript
import React, { Component } from 'react';
import SearchBar from 'react-search-bar-semantic-ui';

class App extends Component {
    render() {
        return(
            <SearchBar data={[{title: "Hello World", description: "This is an example data.", image: "https://via.placeholder.com/150", price: 100}]} />
            );
        }
    }
}

export default App;
```

The demo project can be found [here](https://react-search-bar-sem-ui-demo.herokuapp.com).

Its source code can be found [here](https://github.com/Eric1015/search-app).

The demo project uses the database to retrieve data and passes that to the <code>SearchBar</code> component. It also shows the example of <code>customComponent</code> props. By clicking on the <code>Change Search Result</code> button, it will use the custom search result component to display each result.

Here, the <code>customComponent</code> looks something like the following.

```javascript
const customComponent = (props) => {
    const {title} = props;
    return (
        <div>
            {title && <div className='title custom-result'>{title}</div>}
        </div>
    )
}
```

In the same way, you can retrieve any fields of the object by accessing it through <code>props</code>

### Props

| Name              | Type          | Description                                                         |
| ----------------- | ------------- | ------------------------------------------------------------------- |
| `data`            | `Array`       | An array storing data. Each element needs to have `title` property. |
| `onResultSelect`  | `Function`    | A function that will be called when search result was clicked.      |
| `customComponent` | `Function`    | A component that can be used for the search results shown.          |

* objects in <code>data</code> need to at least have a field <code>title</code> otherwise it will not be shown in the search result
```javascript
const data = [
    {
        title: "Hello",
        // ... whatever other fields
    }
]
```

* <code>onResultSelect</code> needs to follow the following syntax to retrieve result

```javascript
// the resulting object will be stored in variable "result"
function onResultSelect(event, {result}) {
    // do something
}
```

---
_Source: https://npm.io/package/react-search-bar-semantic-ui · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
