Integrations
React
@hopfield/react ships a complete Cmd+K search experience: modal dialog, debounced typeahead, grouped results, and streaming AI answers. Headless hooks are there when you want to own the UI.
Install
npm install @hopfield/reactDrop in the default dialog
import "@hopfield/react/styles.css";
import { Search } from "@hopfield/react";
export function SiteSearch() {
return <Search publicApiKey="hp_public_..." />;
}hotkeydefaults totrue: visitors open the dialog withCmd/Ctrl + K.- Pass
triggerto open it from your own button or fake input. - Control it yourself with
openandonOpenChange.
Custom trigger
import "@hopfield/react/styles.css";
import { Search } from "@hopfield/react";
export function HeaderSearch() {
return (
<Search
publicApiKey="hp_public_..."
trigger={
<button type="button" className="site-search-trigger">
Search docs <kbd>⌘K</kbd>
</button>
}
/>
);
}Theming
The widget adapts to your brand via the theme prop and CSS class overrides (classNames). Colors, radius, and fonts are all adjustable without forking the component.
<Search
publicApiKey="hp_public_..."
theme={{
accentColor: "#0e9f6e",
background: "#ffffff",
textColor: "#0f1a2a",
}}
/>Headless: build your own UI
Use SearchProvider with SearchInput and SearchResults, or go fully custom with useSearchController():
import {
SearchProvider,
SearchInput,
SearchResults,
useSearchContext,
} from "@hopfield/react";
export function CustomSearch() {
return (
<SearchProvider publicApiKey="hp_public_...">
<SearchInput placeholder="Search…" />
<SearchResults />
</SearchProvider>
);
}Related
Using the App Router? See the Next.js guide. Prefer raw HTTP? See the REST API.