Skip to main content
Where styling lives as of SDK v3.2+. Colors, borders, layout, and shadows are driven by CSS custom properties — not by HTML attributes. These variables can be set two ways:
  1. From the Settings API (preferred) — theming is configured per-tenant in the Bonsai dashboard and injected into the component’s shadow DOM automatically at load time.
  2. From your page’s CSS — override any variable on the <bonsai-search> host element (or its container) to customize per-embed. Page CSS wins over the Settings API because Settings-API variables are injected at :host low specificity.
Legacy HTML attributes like brand-color, text-color, input-bg, card-bg, etc. are no longer supported — use the variables on this page instead.

Outer Container

If you want to customize the layout and positioning, wrap the component in a container and add custom CSS.

Example:

CSS Variables

The web component uses a closed shadow root, but CSS custom properties still pass through. You can set any --bonsai-* variables directly on the <bonsai-search> element if you prefer CSS-only customization.

Example:

Reference Table

Defaults shown are for the light theme. The dark theme automatically overrides color and shadow variables.
VariableDefaultPurpose
--bonsai-brand-color#0a5b3bAccent color for focus, buttons, and highlights
--bonsai-text-color#303030Primary text
--bonsai-suggestions-text-color#303030Suggestions text
--bonsai-input-text-color#303030Input text + icon
--bonsai-results-text-color#303030Summary + section headers
--bonsai-card-text-color#303030Result card text
--bonsai-muted-color#9ca3afSecondary text
--bonsai-input-bg#f5f5f5Input + dropdown background
--bonsai-card-bg#f5f5f5Result card background
--bonsai-canvas-color#fafafaPage/canvas background
--bonsai-surface-color#ffffffSurface background
--bonsai-border-colorrgba(0, 0, 0, 0.06)Default border
--bonsai-border-color-hoverrgba(0, 0, 0, 0.12)Hover border
--bonsai-hover-bgrgba(0, 0, 0, 0.04)Hover background
--bonsai-suggestions-hover-bgrgba(0, 0, 0, 0.04)Suggestions hover
--bonsai-error-bgrgba(220, 53, 69, 0.1)Error background
--bonsai-error-color#c82333Error text
--bonsai-space-10.25remSpacing token
--bonsai-space-20.5remSpacing token
--bonsai-space-30.75remSpacing token
--bonsai-space-41remSpacing token
--bonsai-space-51.25remSpacing token
--bonsai-space-61.5remSpacing token
--bonsai-font-headingsystem-ui, -apple-system, sans-serifHeading font
--bonsai-font-bodysystem-ui, -apple-system, sans-serifBody font
--bonsai-font-monoui-monospace, monospaceMono font
--bonsai-font-size-xs0.75remText size
--bonsai-font-size-sm0.875remText size
--bonsai-font-size-base1remText size
--bonsai-font-size-lg1.125remText size
--bonsai-font-size-xl1.25remText size
--bonsai-radius-none0Radius token
--bonsai-radius-sm0.25remRadius token
--bonsai-radius-md0.375remRadius token
--bonsai-radius-lg0.5remRadius token
--bonsai-radius-xl0.75remRadius token
--bonsai-radius-full9999pxFull radius
--bonsai-duration-fast150msAnimation timing
--bonsai-duration-base200msAnimation timing
--bonsai-duration-slow300msAnimation timing
--bonsai-easingcubic-bezier(0, 0, 0.2, 1)Animation easing
--bonsai-shadow-sm0 1px 2px 0 rgb(0 0 0 / 0.05)Shadow token
--bonsai-shadow-md0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)Shadow token
--bonsai-shadow-lg0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)Shadow token
--bonsai-search-min-height3.5remSearch bar height
--bonsai-search-max-width42remMax container width
--bonsai-icon-size1.25remIcon size
--bonsai-icon-size-sm1remSmall icon size
--bonsai-results-columns3Results grid columns
--bonsai-image-object-fitcoverImage sizing mode

Color

--bonsai-brand-color
default:"#0a5b3b"
Accent color used for focus states, buttons, and highlights throughout the component.
--bonsai-text-color
default:"#303030"
Primary text color for main content.
--bonsai-input-text-color
default:"#303030"
Text color for input field and search icon.
--bonsai-suggestions-text-color
default:"#303030"
Text color for suggestion items.
--bonsai-results-text-color
default:"#303030"
Text color for AI summary and section headers.
--bonsai-card-text-color
default:"#303030"
Text color for result card content.
--bonsai-muted-color
default:"#9ca3af"
Secondary text color for less prominent content.
--bonsai-input-bg
default:"#f5f5f5"
Background color for input field and dropdown areas.
--bonsai-card-bg
default:"#f5f5f5"
Background color for result cards.
--bonsai-canvas-color
default:"#fafafa"
Background color for the main canvas area.
--bonsai-surface-color
default:"#ffffff"
Background color for elevated surfaces.
--bonsai-border-color
default:"rgba(0, 0, 0, 0.06)"
Default border color.
--bonsai-border-color-hover
default:"rgba(0, 0, 0, 0.12)"
Border color on hover state.
--bonsai-hover-bg
default:"rgba(0, 0, 0, 0.04)"
Background color for hover states.
--bonsai-suggestions-hover-bg
default:"rgba(0, 0, 0, 0.04)"
Background color when hovering over suggestion items.
--bonsai-error-bg
default:"rgba(220, 53, 69, 0.1)"
Background color for error states.
--bonsai-error-color
default:"#c82333"
Text color for error messages.

Spacing

--bonsai-space-1
default:"0.25rem"
Smallest spacing unit (4px).
--bonsai-space-2
default:"0.5rem"
Extra small spacing unit (8px).
--bonsai-space-3
default:"0.75rem"
Small spacing unit (12px).
--bonsai-space-4
default:"1rem"
Base spacing unit (16px).
--bonsai-space-5
default:"1.25rem"
Medium spacing unit (20px).
--bonsai-space-6
default:"1.5rem"
Large spacing unit (24px).

Typography

--bonsai-font-heading
default:"system-ui, -apple-system, sans-serif"
Font family for headings and section titles.
--bonsai-font-body
default:"system-ui, -apple-system, sans-serif"
Font family for body text.
--bonsai-font-mono
default:"ui-monospace, monospace"
Font family for monospace text.
--bonsai-font-size-xs
default:"0.75rem"
Extra small font size (12px).
--bonsai-font-size-sm
default:"0.875rem"
Small font size (14px).
--bonsai-font-size-base
default:"1rem"
Base font size (16px).
--bonsai-font-size-lg
default:"1.125rem"
Large font size (18px).
--bonsai-font-size-xl
default:"1.25rem"
Extra large font size (20px).

Border Radius

--bonsai-radius-none
default:"0"
No border radius.
--bonsai-radius-sm
default:"0.25rem"
Small border radius (4px).
--bonsai-radius-md
default:"0.375rem"
Medium border radius (6px).
--bonsai-radius-lg
default:"0.5rem"
Large border radius (8px).
--bonsai-radius-xl
default:"0.75rem"
Extra large border radius (12px).
--bonsai-radius-full
default:"9999px"
Full border radius for pill-shaped elements.

Animation

--bonsai-duration-fast
default:"150ms"
Fast animation duration for quick transitions.
--bonsai-duration-base
default:"200ms"
Base animation duration for standard transitions.
--bonsai-duration-slow
default:"300ms"
Slow animation duration for emphasized transitions.
--bonsai-easing
timing-function
default:"cubic-bezier(0, 0, 0.2, 1)"
Easing function for smooth animations.

Shadow

--bonsai-shadow-sm
shadow
default:"0 1px 2px 0 rgb(0 0 0 / 0.05)"
Small shadow for subtle elevation.
--bonsai-shadow-md
shadow
Medium shadow for moderate elevation.
--bonsai-shadow-lg
shadow
Large shadow for prominent elevation.

Layout

--bonsai-search-min-height
default:"3.5rem"
Minimum height for the search bar (56px).
--bonsai-search-max-width
default:"42rem"
Maximum width for the search container (672px).
--bonsai-icon-size
default:"1.25rem"
Standard icon size (20px).
--bonsai-icon-size-sm
default:"1rem"
Small icon size (16px).
--bonsai-results-columns
default:"3"
Number of columns in the results grid layout.
--bonsai-image-object-fit
default:"cover"
CSS object-fit value for product images. Options: cover or contain.

Shadow Parts

The web component uses a closed shadow root, but it exposes stable part hooks for external styling. This lets you style specific inner elements with ::part(...) from outside the component. ::part(...) is supported in modern evergreen browsers. For older browsers, prefer CSS variables or wrapper styling. Example (full part customization):

Reference Table

GroupPartDescription
Searchsearch-wrapperOuter wrapper
Searchsearch-barInput container
Searchsearch-iconLeft icon
Searchsearch-inputInput field
Searchsearch-actionsAction button container
Searchsubmit-buttonSubmit action
Searchloading-stateLoading pill
Searchloading-textLoading text
Searchloading-text-innerEmphasized loading text
SearchspinnerLoading spinner
Searchdone-stateDone pill
Searchdone-textDone text
Searchdone-iconDone icon
Searchreset-buttonReset action
Searchreset-textReset text
Searchreset-iconReset icon
SuggestionssuggestionsSuggestions container
Suggestionssuggestion-itemSuggestion row
Suggestionssuggestion-textSuggestion text
Suggestionssuggestion-arrowSuggestion icon
Footerpowered-byPowered by footer
ResultsresultsResults container
Resultsresults-sectionResults section
Resultsresults-headerResults header
Resultsresults-gridResults grid
ResultssummaryAI summary container
Resultssummary-textAI summary text
Resultsrecommendation-productsRecommendations block
Resultsrecommendation-products-headerRecommendations header
Cardsresult-cardResult card
Cardsresult-image-wrapperResult image wrapper
Cardsresult-imageResult image
Cardsresult-contentResult content
Cardsresult-titleResult title
Cardsresult-price-containerPrice wrapper
Cardsresult-pricePrice
Cardsresult-compare-atCompare-at price
Cardsresult-captionDescription
Statesrecommendations-loadingRecommendations loading container
Statesrecommendations-loading-spinnerRecommendations spinner
Statesrecommendations-loading-textRecommendations text
Statesempty-stateEmpty state
StateserrorError state

Customization Tips

Theme Defaults vs. Overrides

theme="light" (default) and theme="dark" set a full palette of sensible defaults for surfaces, borders, shadows, and text. Any CSS custom properties you set (like --bonsai-text-color, --bonsai-input-bg, or --bonsai-card-bg) override those defaults. theme="auto" uses the visitor’s system preference (prefers-color-scheme) and still respects any explicit overrides.

Where styling values come from

Precedence, highest to lowest:
  1. Your page CSS — any --bonsai-* variable set on the <bonsai-search> host element, on an ancestor, or in a :root rule.
  2. Settings API — values configured per-tenant from the Bonsai dashboard; the component injects a low-specificity :host { ... } block of CSS variables into its shadow DOM at load time.
  3. Built-in theme defaults — the palette for the active theme (light / dark / auto).
Set defaults once in the Settings API to theme all embeds for a tenant; only write page CSS when you need to override a specific embed.

Wrapper Styling

The example includes a wrapper <div> with custom CSS to control the component’s width and positioning. You can modify these styles to match your site’s layout:

Color Scheme

Choose colors that match your brand identity. The component uses your specified colors throughout the interface:
  • --bonsai-brand-color: Used for primary actions and highlights
  • --bonsai-text-color: Used for main content text
  • --bonsai-muted-color: Used for secondary information
  • Background colors: Control the overall appearance
    • --bonsai-input-bg affects the input and the dropdown background
    • --bonsai-card-bg affects result cards
    • --bonsai-surface-color and --bonsai-canvas-color control larger surfaces

Suggestions Best Practices

Create suggestions that:
  • Address common customer questions
  • Highlight popular products or features
  • Use natural, conversational language
  • Are specific to your product catalog