Outer Container
If you want to customize the layout and styling, 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.
| Variable | Default | Purpose |
|---|---|---|
--bonsai-brand-color | #0a5b3b | Accent color for focus, buttons, and highlights |
--bonsai-text-color | #303030 | Primary text |
--bonsai-suggestions-text-color | #303030 | Suggestions text |
--bonsai-input-text-color | #303030 | Input text + icon |
--bonsai-results-text-color | #303030 | Summary + section headers |
--bonsai-card-text-color | #303030 | Result card text |
--bonsai-muted-color | #9ca3af | Secondary text |
--bonsai-input-bg | #f5f5f5 | Input + dropdown background |
--bonsai-card-bg | #f5f5f5 | Result card background |
--bonsai-canvas-color | #fafafa | Page/canvas background |
--bonsai-surface-color | #ffffff | Surface background |
--bonsai-border-color | rgba(0, 0, 0, 0.06) | Default border |
--bonsai-border-color-hover | rgba(0, 0, 0, 0.12) | Hover border |
--bonsai-hover-bg | rgba(0, 0, 0, 0.04) | Hover background |
--bonsai-suggestions-hover-bg | rgba(0, 0, 0, 0.04) | Suggestions hover |
--bonsai-error-bg | rgba(220, 53, 69, 0.1) | Error background |
--bonsai-error-color | #c82333 | Error text |
--bonsai-space-1 | 0.25rem | Spacing token |
--bonsai-space-2 | 0.5rem | Spacing token |
--bonsai-space-3 | 0.75rem | Spacing token |
--bonsai-space-4 | 1rem | Spacing token |
--bonsai-space-5 | 1.25rem | Spacing token |
--bonsai-space-6 | 1.5rem | Spacing token |
--bonsai-font-heading | system-ui, -apple-system, sans-serif | Heading font |
--bonsai-font-body | system-ui, -apple-system, sans-serif | Body font |
--bonsai-font-mono | ui-monospace, monospace | Mono font |
--bonsai-font-size-xs | 0.75rem | Text size |
--bonsai-font-size-sm | 0.875rem | Text size |
--bonsai-font-size-base | 1rem | Text size |
--bonsai-font-size-lg | 1.125rem | Text size |
--bonsai-font-size-xl | 1.25rem | Text size |
--bonsai-radius-none | 0 | Radius token |
--bonsai-radius-sm | 0.25rem | Radius token |
--bonsai-radius-md | 0.375rem | Radius token |
--bonsai-radius-lg | 0.5rem | Radius token |
--bonsai-radius-xl | 0.75rem | Radius token |
--bonsai-radius-full | 9999px | Full radius |
--bonsai-duration-fast | 150ms | Animation timing |
--bonsai-duration-base | 200ms | Animation timing |
--bonsai-duration-slow | 300ms | Animation timing |
--bonsai-easing | cubic-bezier(0, 0, 0.2, 1) | Animation easing |
--bonsai-shadow-sm | 0 1px 2px 0 rgb(0 0 0 / 0.05) | Shadow token |
--bonsai-shadow-md | 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1) | Shadow token |
--bonsai-shadow-lg | 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1) | Shadow token |
--bonsai-search-min-height | 3.5rem | Search bar height |
--bonsai-search-max-width | 42rem | Max container width |
--bonsai-icon-size | 1.25rem | Icon size |
--bonsai-icon-size-sm | 1rem | Small icon size |
--bonsai-results-columns | 3 | Results grid columns |
--bonsai-image-object-fit | cover | Image sizing mode |
Color
Accent color used for focus states, buttons, and highlights throughout the component.
Primary text color for main content.
Text color for input field and search icon.
Text color for suggestion items.
Text color for AI summary and section headers.
Text color for result card content.
Secondary text color for less prominent content.
Background color for input field and dropdown areas.
Background color for result cards.
Background color for the main canvas area.
Background color for elevated surfaces.
Default border color.
Border color on hover state.
Background color for hover states.
Background color when hovering over suggestion items.
Background color for error states.
Text color for error messages.
Spacing
Smallest spacing unit (4px).
Extra small spacing unit (8px).
Small spacing unit (12px).
Base spacing unit (16px).
Medium spacing unit (20px).
Large spacing unit (24px).
Typography
Font family for headings and section titles.
Font family for body text.
Font family for monospace text.
Extra small font size (12px).
Small font size (14px).
Base font size (16px).
Large font size (18px).
Extra large font size (20px).
Border Radius
No border radius.
Small border radius (4px).
Medium border radius (6px).
Large border radius (8px).
Extra large border radius (12px).
Full border radius for pill-shaped elements.
Animation
Fast animation duration for quick transitions.
Base animation duration for standard transitions.
Slow animation duration for emphasized transitions.
Easing function for smooth animations.
Shadow
Small shadow for subtle elevation.
Medium shadow for moderate elevation.
Large shadow for prominent elevation.
Layout
Minimum height for the search bar (56px).
Maximum width for the search container (672px).
Standard icon size (20px).
Small icon size (16px).
Number of columns in the results grid layout.
CSS object-fit value for product images. Options:
cover or contain.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
| Group | Part | Description |
|---|---|---|
| Search | search-wrapper | Outer wrapper |
| Search | search-bar | Input container |
| Search | search-icon | Left icon |
| Search | search-input | Input field |
| Search | search-actions | Action button container |
| Search | submit-button | Submit action |
| Search | loading-state | Loading pill |
| Search | loading-text | Loading text |
| Search | loading-text-inner | Emphasized loading text |
| Search | spinner | Loading spinner |
| Search | done-state | Done pill |
| Search | done-text | Done text |
| Search | done-icon | Done icon |
| Search | reset-button | Reset action |
| Search | reset-text | Reset text |
| Search | reset-icon | Reset icon |
| Suggestions | suggestions | Suggestions container |
| Suggestions | suggestion-item | Suggestion row |
| Suggestions | suggestion-text | Suggestion text |
| Suggestions | suggestion-arrow | Suggestion icon |
| Footer | powered-by | Powered by footer |
| Results | results | Results container |
| Results | results-section | Results section |
| Results | results-header | Results header |
| Results | results-grid | Results grid |
| Results | summary | AI summary container |
| Results | summary-text | AI summary text |
| Results | recommendation-products | Recommendations block |
| Results | recommendation-products-header | Recommendations header |
| Cards | result-card | Result card |
| Cards | result-image-wrapper | Result image wrapper |
| Cards | result-image | Result image |
| Cards | result-content | Result content |
| Cards | result-title | Result title |
| Cards | result-price-container | Price wrapper |
| Cards | result-price | Price |
| Cards | result-compare-at | Compare-at price |
| Cards | result-caption | Description |
| States | recommendations-loading | Recommendations loading container |
| States | recommendations-loading-spinner | Recommendations spinner |
| States | recommendations-loading-text | Recommendations text |
| States | empty-state | Empty state |
| States | error | Error 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 explicit color props (like text-color, input-bg, or card-bg) override those defaults.
theme="auto" uses the visitor’s system preference (prefers-color-scheme) and still respects any explicit overrides.
Attributes vs. CSS Variables
Use attributes for simple configuration and consistent defaults. Use CSS variables when you want to theme multiple values at once, share a design system across multiple components, or adjust tokens like spacing, shadows, and typography.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:- Brand color: Used for primary actions and highlights
- Text color: Used for main content text
- Muted color: Used for secondary information
- Background colors: Control the overall appearance
input-bgaffects the input and the dropdown backgroundcard-bgaffects result cardssurface-colorandcanvas-colorcontrol 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