1.1.9 • Published 2 years ago

react-searchable-component v1.1.9

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

react-searchable-component

Simple React component for a search input, providing a filter function.

Demo

Install

npm install react-searchable-component

Example

import React, { useState } from 'react';
import { SearchableBox, BoxItem } from 'react-searchable-component';

function App() {
  const array = [
    {
      id: 1,
      name: 'Youtube',
      imageUrl: 'https://www.youtube.com/favicon.ico',
    },
    {
      id: 2,
      name: 'Facebook',
      imageUrl: 'https://www.facebook.com/favicon.ico',
    },
    {
      id: 3,
      name: 'Twitter',
      imageUrl: 'https://www.twitter.com/favicon.ico',
    },
    {
      id: 4,
      name: 'Instagram',
      imageUrl: 'https://www.instagram.com/favicon.ico',
    },
    {
      id: 5,
      name: 'Reddit',
      imageUrl: 'https://www.reddit.com/favicon.ico',
    },
  ];

  const [theme, setTheme] = useState(false);
  const [isAlwaysOpen, setIsAlwaysOpen] = useState(true);
  const [title, setTitle] = useState('Type to search');

  return (
    <div>
      <SearchableBox
        darkTheme={theme}
        placeholder
        title={title}
        items={array}
        alwaysOpen={isAlwaysOpen}
      >
        {(items) =>
          items.map((item, index) => (
            <BoxItem key={index}>
              <div>
                <img src={item.imageUrl} alt="" width={22} />
              </div>
              <div>{item.name}</div>
            </BoxItem>
          ))
        }
      </SearchableBox>
    </div>
  );
}

export default App;
1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago