Skip to content
Sign upPro
FramesSearch pageMenu

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.

The query types in, the answer streams with numbered citations, citation 2 lights its result and source, and your site is marked cited. Loops; point at a citation to take over.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/search-page.json

Usage

tsx
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.

Results only, a collapsed answer, streaming, your site cited, a phone viewport and dark.

Props

PropTypeNotes
querystringShown in the field and the address
answer{ text, cite } | ReactNodeText with [n] citations, or your own node
results{ id, domain, path?, title, snippet, sponsored?, href? }[]Titles are links when href is set
streamingbooleanWord by word with the caret
highlightstringYour domain; subdomains match
active, defaultActive, onActiveChangenumber | nullThe lit citation
expanded, defaultExpanded, onExpandedChangebooleanLong answers start collapsed
asideReactNodeRight rail from 1100 px
brandstringThe text wordmark. Default Peruse
tabs, tab, onTabChangestring[], stringDefault All to Shopping
onQueryChange, onSearch(query) => voidMake the field editable
chrome, addressbrowser | none, stringThe browser bar and its address
answerLabel, placeholderstringDefault “Overview” and “Search or ask a question…”
emptyReactNodeNo results; null shows nothing
clearingbooleanFades the answer and results out before a loop restarts
viewport, width, bezel, radiusFrame propsDefault 1280 by 900, hairline, 12

Helpers: parseCitations(text) returns the paragraphs as words with their citations, and matchesDomain(domain, highlight) is the highlight rule.