Skip to main content

How configuration works

Starting with SDK v3.2, the <bonsai-search> component has two configuration sources:
  1. HTML attributes you set on the tag — the commonly used ones are listed below, with the rest under Additional attributes.
  2. Runtime configuration from the Settings API — theming (colors, layout, max width, alignment), default labels, default placeholder, default suggestions, and feature toggles (markdown, price rendering, autocomplete, etc.). These are fetched per-tenant by the component at load time from /rest/search-component-config/ using your api-key, and they are applied automatically.
Where theming lives now. Colors, borders, alignment, and width are not HTML attributes anymore. They are either returned by the Settings API (preferred — managed per tenant from the Bonsai dashboard) or overridden locally via CSS custom properties on the host element. See Advanced Styling for the full CSS variable list.

Precedence

For any given value, the component resolves in this order:
  1. HTML attribute on the tag (if set)
  2. Settings API response for this api-key (if provided)
  3. Built-in default
So you can leave the tag minimal (just api-key) and let the dashboard drive the rest, or override a specific value on the tag when you need to.
Colours are the exception. Under theme="dark" (or theme="auto" on a dark-preference machine) 21 colour and shadow variables are fixed by the theme and cannot be overridden by page CSS or by the Settings API. See Dark theme.

Attributes

The most commonly used attributes on <bonsai-search>: Legacy colour attributes (brand-color, text-color, input-bg, card-bg, …) were removed in v3.2.0 and are ignored. Use CSS custom properties or the Settings API instead — see Advanced Styling.

Additional attributes

Less common, but read by the component:

Required Attributes

required
Your Bonsai API key. Required for the search component to function and to fetch runtime configuration from the Settings API.

API Configuration

default:"https://api.hibonsai.com"
The API origin. Optional — omit it and the component uses the production origin. The Settings API URL is derived from this value automatically.
The path is not yours to choose. Whatever path you write here is replaced at load time by the search version configured for your organization (api.search_path in the Settings API response), so .../rest/search/v3/ on the tag does not mean v3 is what gets called. Set the origin only, or pin it deliberately:
Boolean attribute. Keeps the path you wrote in base-url instead of adopting your organization’s configured search version. Use it when an embed must stay on one specific version regardless of dashboard changes.
Requests are rejected unless the page’s origin is allowed for your organization. Three things are allowed automatically: the Bonsai dashboard, any https://*.shopifypreview.com preview, and — on non-production environments only — http://localhost:3000, http://localhost:3001 and the matching 127.0.0.1 ports.Everything else, including every localhost port you develop against production, has to be registered per organization. Send your CSM the full list of origins you need — production, staging, preview, and the local port you work on — before you start. A page whose origin is not on that list fails the CORS preflight, and the component reports Failed to fetch.Pages opened directly from disk (file://) send an origin of null and are never allowed; serve your test page over HTTP instead.

User Experience

default:"Describe what you're looking for..."
The placeholder text displayed in the search input field. If omitted, the value from the Settings API is used; otherwise the built-in default.
default:"[]"
A JSON array of suggested search queries that appear below the search input. If omitted, the Settings API content.suggestions list is used.
The suggestions attribute must be a valid JSON array string. Use single quotes around the attribute value and double quotes for the array items.
default:"50"
The maximum number of search results to display.
default:"30000"
The request timeout in milliseconds.

Display Options

default:"false"
Boolean attribute that enables price display in search results. Presence of the attribute is sufficient to enable it.
default:"true"
Controls whether the price is displayed alongside the product title.
default:"false"
Boolean attribute that enables markdown rendering in AI summaries and content.
default:"light"
Color theme for the component. Options: light, dark, or auto (follows the user’s system preference).
default:"cover"
Sets the --bonsai-image-object-fit CSS variable. Options: cover or contain.
default:"false"
Boolean attribute — when present, product results are hidden and only the AI summary is shown. Useful for conversational integrations.

Results Section Labels

The heading text displayed above AI-recommended products.
default:"More Items"
The heading text displayed above additional results when AI recommendations are present.
default:"Items"
The heading text displayed above results when there are no AI recommendations.

Callbacks

Name of a globally-accessible function used to format prices before they are rendered. The function receives (result, price, parent) and must return the string to display.

Styling

All visual customization (colors, borders, alignment, max width, hover states) is done via either:
  • The Settings API — preferred. Configure per-tenant in the Bonsai dashboard; the component picks up the values automatically.
  • CSS custom properties on the host element — to override per-embed.
See Advanced Styling for the full list of CSS variables and override examples.