The sources behind an AI answer, shown as a search pill, source cards, a streaming answer, and inline citations.
Press Replay to watch a search run and the answer type itself out. Hover the favicons to fan them out, and hover a citation to preview its source.
Options you can pass to customize this component.
sources*WebSource[]The results, each an id, a title, and a url, plus an optional snippet and favicon. Without a favicon, a colored letter stands in.
statussearchingdoneSearching shimmers the label and holds empty slots for results still on the way.
querystringShown in the label while searching.
labelstringReplaces the label. By default it reads "Searching the web", then "Searched 6 sites".
progressnumberHow far the search is, 0 to 1, drawn as the ring around the globe. Leave it out and the ring fills a step with each source.
linkedbooleanWhether cards and citations open their source in a new tab. Turn it off to keep visitors on the page; the previews still work.
openbooleanPass this to control whether the cards show. Pair it with onOpenChange.
defaultOpenbooleanWhether the cards show on first render.
onOpenChange(open: boolean) => voidCalled each time the cards show or hide.
playbooleanOn WebSearchAnswer only. Starts typing the answer. Paragraphs, lists, and bold text are typed into; citations land whole. Children that grow later are typed in as they arrive.
speednumberOn WebSearchAnswer only. Average characters per second. A long backlog types faster so a live stream never falls behind.
onComplete() => voidOn WebSearchAnswer only. Called once the last character is typed.
sourceWebSourceOn WebSearchCitation only. The source the inline chip links to and previews.
indexnumberOn WebSearchCitation only. A number shown after the site name, for numbered references.
classNamestringExtra classes merged onto the root element (data-slot="web-search", with data-status). The width defaults to 560px.
npx shadcn@latest add swamimalode07/rare-ui/web-search"use client"import {WebSearch,WebSearchAnswer,WebSearchCitation,} from "@/components/ui/web-search"const sources = [{id: "mdn",title: "prefers-reduced-motion",url: "https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion",snippet: "Detects if the user asked for less motion.",},]export function Answer() {return (<div><WebSearch sources={sources} /><WebSearchAnswer>Turn animations off when the user asks for less motion{" "}<WebSearchCitation source={sources[0]} />.</WebSearchAnswer></div>)}// while results stream in, pass status="searching" and grow the array
Click the code icon in the top-right corner to view the source code.
Most components here are recreations of great work from around the web. I don't claim to be the original creator - this is my attempt to reverse-engineer, replicate, and often add a few extra features. I've tried to credit everyone; if I missed someone, let me know.
1