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:Legacy HTML attributes like
- 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.
- From your page’s CSS — set any variable on the
<bonsai-search>element itself to customize per-embed. Page CSS wins over the Settings API because Settings-API variables are injected at:hostlow specificity.
Target the element, not an ancestor. The SDK declares its defaults on
:host — a direct declaration on the component — so a value that merely inherits down from :root or a wrapper <div> loses to it. bonsai-search { --bonsai-text-color: … } works; :root { --bonsai-text-color: … } does not.theme="dark" overrides both of the above. The dark palette is declared on an element inside the component’s shadow root, so it beats page CSS, inline style="", and the Settings API alike — 21 colour and shadow variables are silently discarded. Read Dark theme before styling a dark embed.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:
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:
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:"transparent"
Background color for result cards. Defaults to
transparent, so cards sit directly on your page background unless you set a surface.default:"#fafafa"
Background color for the main canvas area. Declared but not consumed by the SDK — setting it currently has no effect.
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. Declared but not consumed by the SDK — setting it currently has no effect.
default:"0.25rem"
Small border radius (4px). Declared but not consumed by the SDK — setting it currently has no effect.
default:"0.375rem"
Medium border radius (6px).
default:"0.5rem"
Large border radius (8px).
default:"0.75rem"
Extra large border radius (12px). Declared but not consumed by the SDK — setting it currently has no effect.
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. Declared but not consumed by the SDK — setting it currently has no effect.
shadow
Medium shadow for moderate elevation. Declared but not consumed by the SDK — setting it currently has no effect.
shadow
Large shadow for prominent elevation.
Layout
default:"3.5rem"
Minimum height for the search bar (56px). Declared but not consumed by the SDK — setting it currently has no effect.
default:"42rem"
Maximum width for the search container (672px).
default:"1.25rem"
Standard icon size (20px). Declared but not consumed by the SDK — setting it currently has no effect.
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.Dark theme
theme="dark" cannot be re-coloured. Its palette is declared on an element inside the component’s shadow root, so page CSS, inline style="", !important, and Settings-API colours are all outranked. The 21 variables below are discarded whenever theme resolves to dark — including theme="auto" on a visitor whose system prefers dark.The 21 variables theme="dark" takes over
Everything else —
--bonsai-brand-color, the fonts, spacing, radii, --bonsai-search-max-width, --bonsai-image-object-fit, --bonsai-content-padding, --bonsai-card-radius, --bonsai-image-radius — is untouched by the theme and can be set normally.
How to build a dark embed you control
Settheme="light" and supply the dark palette yourself. On the light theme nothing inside the shadow root re-declares these variables, so every value on the element takes effect.
The block below is the built-in dark palette, copied out so you can edit it. A component with theme="light" and this CSS looks the same as theme="dark" — the difference is that these lines now work.
Start from this block, which reproduces the built-in dark palette exactly, and change the values you want:
Copy the whole block, not only the lines you want to change.
theme="light" puts the component on the light palette, so any variable you leave out falls back to a light default — an invisible rgba(0, 0, 0, 0.06) border on a black page, for example.Following the system preference
theme="auto" is subject to the same restriction, so drive it from your own media query instead:
If you must keep theme="dark"
Use Shadow Parts. ::part() rules are written from your page against elements the component exposes, and they set properties directly rather than through an inherited variable, so they are not affected:
Recolour the caption and price alongside the title. They inherit
--bonsai-card-text-color, which under theme="dark" stays light — on a light card the caption renders near-invisible at its 0.7 opacity.Shadow Parts
The web component uses a closed shadow root, but it exposes stablepart 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" (the default) sets a palette of light defaults for surfaces, borders, shadows, and text. Any --bonsai-* custom property you set on the host overrides those defaults, because they are declared at :host inside the shadow root and your page sits outside it.
theme="dark" behaves differently, and the difference is not cosmetic: its palette is declared on an element inside the shadow root, which your page cannot reach by selector. Under theme="dark" the 21 variables listed in Dark theme ignore anything you set. See that section for the supported way to build a dark embed.
theme="auto" resolves to light or dark from the visitor’s prefers-color-scheme, so on a dark-preference machine it has exactly the dark behaviour above. Treat auto as dark for styling purposes.
Where styling values come from
Precedence, highest to lowest:- The active
theme’s dark palette — only whenthemeresolves todark, and only for the 21 variables it declares. Nothing below can override these. - Your page CSS — any
--bonsai-*variable set on the<bonsai-search>element itself. Not an ancestor and not:root: the SDK declares its defaults on:host, and a direct declaration always beats an inherited one. - 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. Because this is a:hostblock, it is also outranked by the dark palette. - Built-in light defaults.
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-bgaffects the input and the dropdown background--bonsai-card-bgaffects result cards--bonsai-surface-coloraffects elevated surfaces such as the image placeholder--bonsai-canvas-coloris not read by the SDK — the component draws no page background of its own. Set the background on your own container or<body>instead
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