> For the complete documentation index, see [llms.txt](https://docs.fact-finder.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fact-finder.com/webcomponents-overview/web-components-4.x./api/basic-elements/searchbox.md).

# Searchbox

Configure search inputs, buttons, and suggestion behavior.

## Documentation

### Wrapping input element with ff-searchbox <a href="#wrapping-input-element-with-ff-searchbox" id="wrapping-input-element-with-ff-searchbox"></a>

The `ff-searchbox` wraps a regular HTML `<input>` element. Simply place `<input>` between `<ff-searchbox>` tags. On ENTER a search query to FactFinder is fired with the current input value.

```html
<ff-searchbox>
    <input />
</ff-searchbox>
```

**Placeholder**

Because the `ff-searchbox` does not limit features of HTML it wraps, you can use all the standard attributes of `<input>` such as `placeholder`.

```html
<ff-searchbox>
    <input placeholder="Search..." />
</ff-searchbox>
```

**Select input value on click**

With the `select-onclick` attribute you can define whether the value should be selected when the search box gets focus. *(default is `"false"`)*

```html
<ff-searchbox select-onclick="true">
    <input />
</ff-searchbox>

```

### Adding Suggest <a href="#adding-suggest" id="adding-suggest"></a>

If you want a Suggest functionality on your page you can set the `use-suggest` attribute to `"true"` *(default is `"true"`)*. You also need to implement the `ff-suggest` tag on your page. For more information take a look at the [Suggest Example](https://web-components.fact-finder.de/api/4.x/ff-suggest). The Suggest will only trigger when at least 2 characters are typed in the input field.

```html
<ff-searchbox use-suggest="true">
    <input />
</ff-searchbox>
```

**On Focus**

With the property `suggest-onfocus` set to `"true"`, the Suggest will open when the user clicks into the input or the input gets focus.

```html
<ff-searchbox suggest-onfocus="true">
    <input />
</ff-searchbox>
```

**Hiding Suggest**

Usually, you want the Suggest to disappear once the user clicks somewhere else. This happens with the default settings.

The default settings are **no longer recommended**, however.

Instead, you should prefer to set `ff-searchbox`'s `hide-suggest-onblur` attribute to `"false"` and set `ff-suggest`'s `hide-onblur` to `"true"`.

See [ff-suggest](https://web-components.fact-finder.de/api/4.x/ff-suggest) for more details.

```html
<ff-searchbox hide-suggest-onblur="false"></ff-searchbox>
```

### Wrapping button element with ff-searchbutton <a href="#wrapping-button-element-with-ff-searchbutton" id="wrapping-button-element-with-ff-searchbutton"></a>

The `ff-searchbutton` wraps a regular HTML `<button>` element. Surrounded with `<ff-searchbutton>` tag it becomes a special button which connects to the search box and sends a search request to FactFinder.

```html
<ff-searchbutton>
    <button>Search</button>
</ff-searchbutton>
```

## Demo

Try the [Searchbox demo](https://search-web-components.fact-finder.de/demos/4.x/ff-searchbox).

## API code

### `ff-searchbox`

**Properties**

<details>

<summary>Properties</summary>

| Name                                                                             | Description                                                                      |
| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| **suggest-onfocus** (String) **Options**: "true", "false" (default: "false")     | Displays a FactFinder Suggest recommendation when the search box receives focus. |
| **hide-suggest-onblur** (String) **Options**: "true", "false" (default: "true")  | Set this to `"false"` and use `ff-suggest`'s `hide-onblur="true"` instead.       |
| **select-onclick** (String) **Options**: "true", "false" (default: "false")      | Selects the search box contents when clicked.                                    |
| **use-suggest** (String) **Options**: "true", "false" (default: "true")          | Sends suggest requests while a user types.                                       |
| **suggest-delay** (Number) (default: 0)                                          | Waits before sending a suggest request.                                          |
| **value** (String) (default: empty)                                              | Gets or sets the related `<input>` value.                                        |
| **show-asterisk-query** (String) **Options**: "true", "false" (default: "false") | Shows a single asterisk query in the input field.                                |

</details>

**Events**

<details>

<summary>Events</summary>

| Name               | Description                                                            |
| ------------------ | ---------------------------------------------------------------------- |
| **before-search**  | Fires before a search and provides the current search event.           |
| **before-suggest** | Fires before a suggest request and provides the current suggest event. |

</details>

**Methods**

<details>

<summary>Methods</summary>

| Name                               | Description                    |
| ---------------------------------- | ------------------------------ |
| **search()**                       | Starts a search.               |
| **resetInput(selector = 'input')** | Sets the nested input element. |

</details>

### `ff-searchbutton`

**Methods**

<details>

<summary>Methods</summary>

| Name                                 | Description                     |
| ------------------------------------ | ------------------------------- |
| **resetButton(selector = 'button')** | Sets the nested button element. |

</details>

**Events**

<details>

<summary>Events</summary>

| Name              | Description                       |
| ----------------- | --------------------------------- |
| **before-search** | Fires when the button is pressed. |

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fact-finder.com/webcomponents-overview/web-components-4.x./api/basic-elements/searchbox.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
