Search page
A search results page with an answer above the links. Numbered citations light up their result and source card, and a highlight option rings your own site and marks it cited.
On this page
Installation
Usage
import { SearchPage } from "@/components/ui/chatcn/search-page"
<SearchPage
query="how often to replace running shoes"
answer={{
text: "Most running shoes last 300 to 500 miles.[1] Check the midsole for deep creases.[2]",
cite: { 1: "almanac", 2: "milepost" },
}}
results={[
{ id: "almanac", domain: "runnersalmanac.com", path: ["training"], title: "…", snippet: "…" },
{ id: "milepost", domain: "milepostrunning.com", path: ["guides"], title: "…", snippet: "…" },
]}
highlight="milepostrunning.com"
/>The page lays out at a true 1280 by 900 viewport and scales to fit. From 1100 px it has a right rail for aside (a fact panel you compose); under 700 px it is one column and the sources scroll sideways. The address bar shows the search URL; chrome="none" drops it.
Write [n] after a word to cite source n; cite maps each number to a result id. The pill stays on the same line as the word before it, so it never wraps alone. Hovering or focusing a pill lights its result and its source card, and the pill is described by the result's title for screen readers. Clicking it scrolls the result into view inside the frame, never the page around it.
With streaming, the answer shows word by word, 28 ms a word, behind the kit's caret, and catches up at the same pace once streaming turns off. Every word is laid out from the start, so lines never rewrap and nothing below the answer moves. Before the first word, Thinking shows after 300 ms. Answers taller than seven lines collapse with a fade and Show more; tabbing to a citation under the fade opens it.
highlight takes a domain and matches it without case, www. or a path, including subdomains. Matching results and source cards get a ring in your primary color; results the answer cites get a Cited chip that never moves the domain line, and the pills that cite you take a tint.
Examples
States
Results only with a sponsored result, a collapsed answer, streaming, your site cited, a phone viewport inside PlainScreen, and dark.
Props
| Prop | Type | Notes |
|---|---|---|
query | string | Shown in the field and the address |
answer | { text, cite } | ReactNode | Text with [n] citations, or your own node |
results | { id, domain, path?, title, snippet, sponsored?, href? }[] | Titles are links when href is set |
streaming | boolean | Word by word with the caret |
highlight | string | Your domain; subdomains match |
active, defaultActive, onActiveChange | number | null | The lit citation |
expanded, defaultExpanded, onExpandedChange | boolean | Long answers start collapsed |
aside | ReactNode | Right rail from 1100 px |
brand | string | The text wordmark. Default Peruse |
tabs, tab, onTabChange | string[], string | Default All to Shopping |
onQueryChange, onSearch | (query) => void | Make the field editable |
chrome, address | browser | none, string | The browser bar and its address |
answerLabel, placeholder | string | Default “Overview” and “Search or ask a question…” |
empty | ReactNode | No results; null shows nothing |
clearing | boolean | Fades the answer and results out before a loop restarts |
viewport, width, bezel, radius | Frame props | Default 1280 by 900, hairline, 12 |
Helpers: parseCitations(text) returns the paragraphs as words with their citations, and matchesDomain(domain, highlight) is the highlight rule.