> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hibonsai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bonsai Search Bar

> Self-serve guide for integrating the Bonsai Search Bar web component into your website

## Getting Started

Before getting started, ensure that you've had a chance to review the [Quickstart prerequisites](/project/docs/quickstart#prerequisites).

Once you have your API key, you can integrate Bonsai AI Search Bar into any website in just a few minutes using our web component.

<Callout color="#0A5B3B" icon="circle-alert">
  If you need the full search experience with AI summary and product results,<br />use the [Bonsai Search Web Component](/project/docs/bonsai-search/integration) instead.
</Callout>

## Quick Installation

Use this minimal 2-step setup to render Bonsai Search Bar on your website.

<Callout color="#0A5B3B" icon="info">
  **Theming is managed in the Bonsai dashboard.** When the component loads, it fetches your tenant's theme and behavior settings from the Settings API using your `api-key` and applies them automatically. You can also override values per-embed via CSS custom properties set on the `<bonsai-searchbar>` element — see [Advanced Styling](/project/docs/bonsai-searchbar/styling).

  Building a **dark** search bar? `theme="dark"` fixes the colour variables so neither the dashboard nor your page CSS can change them. Read [Dark theme](/project/docs/bonsai-searchbar/styling#dark-theme) first.
</Callout>

<Steps>
  <Step title="Install the script">
    Add the Bonsai Search Bar `<script>` tag to your HTML page. Place this in the `<head>` section, or before the closing `</body>` tag.
    This ensures the script is loaded before the component is rendered.

    ```html theme={null}
    <script
      src="https://assets.hibonsai.com/sdk/bonsai-searchbar-webcomponent-latest.js"
      defer
    ></script>
    ```
  </Step>

  <Step title="Add the component">
    Add `<bonsai-searchbar>` where you want the redirecting search bar to appear. Only `api-key` is required — the component fetches its placeholder text and suggestion chips from the Settings API using your `api-key`. Colors are set via CSS custom properties (legacy color attributes are ignored).

    ```html theme={null}
    <style>
      bonsai-searchbar {
        --bonsai-brand-color: #0A5B3B;
        --bonsai-text-color: #303030;
        --bonsai-muted-color: #9CA3AF;
        --bonsai-input-bg: #f5f5f5;
      }
    </style>

    <bonsai-searchbar
      api-key="API-KEY"
      theme="light"
    ></bonsai-searchbar>
    ```

    <Callout color="#0A5B3B" icon="info">
      **Most content comes from the Settings API.** Placeholder text, suggestions and autocomplete are configured per-tenant in the Bonsai dashboard and returned by `/rest/search-component-config/` when the component loads, so a minimal tag is usually enough.

      Two things are set on the tag, never from the dashboard: `search-path`, the page this search bar redirects to on submit (defaults to `/ai-search`), and `close-button`, which is read from the attribute only.

      If you need to override any other value for a single embed, you can still pass the corresponding attribute — it takes precedence over the Settings API response — but prefer the dashboard so every embed stays in sync.
    </Callout>
  </Step>

  <Step title="Test the search bar with a query">
    Not working? Check the [Troubleshooting](/project/docs/troubleshooting) guide for common issues.
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="Configuration" icon="sliders-horizontal" href="/project/docs/bonsai-searchbar/config">
    Full attribute reference and default values for the Search Bar component.
  </Card>

  <Card title="Events Reference" icon="radio" href="/project/docs/bonsai-searchbar/events">
    The `close` event, and putting the search bar behind a trigger in your header.
  </Card>

  <Card title="Advanced Styling" icon="palette" href="/project/docs/bonsai-searchbar/styling">
    `::part(...)` usage and full parts reference for Search Bar customization.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.