> For the complete documentation index, see [llms.txt](https://docs.rowsncolumns.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rowsncolumns.app/configuration/features/search.md).

# Search

`useSearch` hook gives you some basic defaults for search and outputs a `borderStyles` prop so that the grid can highlight the cells.

`SheetSearch` is a generic form input that shows and hides when search is active.

<pre class="language-typescript" data-overflow="wrap"><code class="lang-typescript"><strong>import { SpreadsheetProvider, CanvasGrid, SheetSearch } from "@rowsncolumns/spreadsheet";
</strong>import { useSearch } from "@rowsncolumns/spreadsheet-state"

const MySpreadsheet = () => {
  const { getCellData, getNonEmptyColumnCount, getNonEmptyRowCount } = useSpreadsheetState()
  
  const {
    onSearch,
    onResetSearch,
    onFocusNextResult,
    onFocusPreviousResult,
    hasNextResult,
    hasPreviousResult,
    borderStyles,
    isSearchActive,
    onRequestSearch,
  } = useSearch({
    getCellData,
    sheetId: activeSheetId,
    getNonEmptyColumnCount,
    getNonEmptyRowCount,
  });
  
  return (
    &#x3C;>
      &#x3C;CanvasGrid
        ...
        onRequestSearch={onRequestSearch}
        borderStyles={borderStyles}
      />
      
      // Make sure you have a parent div with position: relative
      &#x3C;SheetSearch
        isActive={isSearchActive}
        onSubmit={onSearch}
        onReset={onResetSearch}
        onNext={onFocusNextResult}
        onPrevious={onFocusPreviousResult}
        disableNext={!hasNextResult}
        disablePrevious={!hasPreviousResult}
      />
    &#x3C;/>
  );
};

const App = () => (
  &#x3C;SpreadsheetProvider>
    &#x3C;MySpreadsheet />
  &#x3C;/SpreadsheetProvider>
);
</code></pre>
