1.3.0 β€’ Published 2 years ago

react-search-dialog v1.3.0

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

React Search DialogπŸ”Ž Version NPM bundle size

A batteries included search component that aims to make implementing a modern search experience in your application as easy as possible.

With a focus on performance and not reinventing the wheel, React Search Dialog is built on top of battle tested libraries Fuse.js and react-window so that no matter the item list, you'll get the results you're looking for near instantly!

Features

  • βœ… Handles massive data sets with ease
  • βœ… Live results as you type
  • βœ… Out of the box styling, with ability to customize as needed
  • βœ… Mobile friendly
  • βœ… Optional render functions for search results and recent items
  • βœ… Built in recent search history (with ability to disable)
  • βœ… Optional quick select section for common search items (fully customizable)

Examples

🚧 Coming soon!

Props

Below is a table of all props exposed by the Search component. The majority of this table is a pared down, more digestible version of the exported type SearchProps so if more detail is needed, please feel free to refer to the type definitions directly!

Key
βœ…Required
⚠Conditionally Optional
❌Optional
RequiredProp NameProp TypeDescription
βœ…itemsArray of T (generic)The items to search through. IMPORTANT: T must have a label property OR be a string.
⚠onItemSelect(item: T) => voidCallback to fire when an item is selected. IMPORTANT: When NOT passing in your own render function with renderResult, this prop is required so that an action can be taken on search result / recent click.
❌buttonPropsButtonProps OR (isSmallScreen: boolean) => ButtonPropsProps to pass to the button that opens the search dialog. Click here to read more about the props available to the Button component
❌placeholderstringThe placeholder text to display in the search input
❌quickFillTitlestringThe title used for the quick fill section of the search dialog
❌itemHeightnumber or ItemHeightPresetHeight of each item in the search results
❌quickFillItemsArray of T (generic)Items to display in the quick fill section
❌maxHeightstring or numberMaximum height of the search dialog
❌maxWidthstring or numberMaximum width of the search dialog
❌noHistorybooleanWhether or not to record or display recent search history
❌renderResult({ item, smallDisplay, closeDialog, addToRecents }) => JSX.ElementCallback to render a single search result IMPORTANT: Because you're supplying the render function for each search result, it's up to you to use the addToRecents function when a selection is made by the user, and the closeDialog function when you see it appropriate for the search dialog to close.
❌renderRecent({ item, smallDisplay, closeDialog, addToRecents }) => JSX.ElementCallback to render a single recent search item IMPORTANT: Because you're supplying the render function for each recent search item, it's up to you to use the addToRecents function when a selection is made by the user, and the closeDialog function when you see it appropriate for the search dialog to close.