Reference table
It bubbles and is composed, so you can listen on the element or on any ancestor.
There is no
search or results event on the search bar. Submitting navigates to `${search-path}?q=${query}` — the page unloads, so an event fired at that moment would be of no use to you. The results arrive on the destination page, where <bonsai-search> events give you search, results, ai and error.The pattern this exists for
close-button is how a search bar lives behind a trigger in a site header instead of taking up a row permanently. The button renders inside the component, so the close event is the only way your page learns it was pressed — otherwise your trigger and the bar disagree about whether the bar is open.
In React this is the one part of a search-bar install that needs
"use client" — the component itself does not. Return focus to your trigger after a close, so keyboard users are not dropped at the top of the document.Methods
Call these on the element once the SDK has upgraded it — from an effect, an event handler, or after the script’sload, never during the first render.
theme and close-button are also live attributes — set them on the element at runtime and the component reacts, so you do not need a method for either.