# UseSearch

What [`useSearch`](https://docs.mapcairn.com/api/map/useSearch-function.md) returns.

This is an interface exported by `@mapcairn/map`, checked against version 0.2.0.

## Signature

```ts
import type { UseSearch } from "@mapcairn/map";
 
interface UseSearch
```

## Properties

### clear

```ts
readonly clear: () => void;
```

Empties the box and cancels everything.

### query

```ts
readonly query: string;
```

The text in the search box.

### retry

```ts
readonly retry: () => void;
```

Runs the current query again at once, for the Retry button.

### setQuery

```ts
readonly setQuery: (query: string) => void;
```

Sets the text as the user typed it. Never searches: it cancels any search
in flight and returns to `idle`, so results for older text never sit
under new text.

### settle

```ts
readonly settle: (query: string) => void;
```

Puts text in the box without searching: cancels anything in flight and
returns to `idle`. Used when the user picks a result, so the box shows
its label.

### state

```ts
readonly state: SearchState;
```

Where the search stands.

### submit

```ts
readonly submit: () => void;
```

Searches for the current text, for Enter or the Search button. Answers a
coordinate pair itself, without the provider. Does
nothing when the trimmed text is shorter than `MIN_SEARCH_LENGTH`,
or when the text's own search is already loading or showing its outcome
(after a failure it searches again).

## See also

- [`SearchState`](https://docs.mapcairn.com/api/map/SearchState.md)

Source: [packages/map/src/tools/SearchPill/useSearch.ts:60](https://github.com/MapCairn/mapcairn/blob/main/packages/map/src/tools/SearchPill/useSearch.ts#L60)
