# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rowsncolumns.app/configuration/features/search.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
