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.

Color

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

Spacing

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

Typography

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

Border Radius

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

Animation

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

Shadow

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

Layout

default:"3.5rem"
Minimum height for the search bar (56px).
default:"42rem"
Maximum width for the search container (672px).
default:"1.25rem"
Standard icon size (20px).
default:"1rem"
Small icon size (16px).
default:"3"
Number of columns in the results grid layout.
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

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