# Search Result Card

One ranked result of a web-search tool call: source, relevance, title and snippet.

- Category: AI & Agents
- Page: https://wunderui.com/components/search-result-card
- Tier: Core and Pro

## Install

Search Result Card ships with WunderUI Core and Pro in the @wunderui/react package.

## Import

```tsx
import { SearchResultCard, SearchResult, SearchResultRow } from "@wunderui/react"
```

## Minimal usage

Then use it:

```tsx
import { SearchResultCard } from "@wunderui/react"

export function Result() {
  return (
    <SearchResultCard
      rank={1}
      title="Keyboard interaction for tabs"
      url="https://wunderui.com/components/tabs"
      snippet="Arrow keys move focus between tabs."
      relevance={0.94}
    />
  )
}
```

Expected result: You see a card with the number 1, the link icon with wunderui.com and /components/tabs, a 94% match badge, the title as a link and the snippet below. The link opens in a new tab.

## When to use

### Use Search Result Card for

- The ranked results of a web-search or document-search tool call
- A result the agent's answer cites, marked next to the ones it did not use
- Results from the open web, where host and path help judge the source

### Use something else

- [Source List](https://wunderui.com/components/source-list) for the sources pinned under a final answer, as a compact list
- [Chat Source](https://wunderui.com/components/chat-source) for a source cited inside a chat message
- [List Group](https://wunderui.com/components/list-group) for any other list of rows that are not search results

## Keyboard

The only control is the title link, a native anchor, so the browser handles focus and activation.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the title link of the next or previous card. Nothing else in the card takes focus. |
| `Enter` | Opens the page in a new tab. The opener and the referrer are not passed on. |

## Behavior

How the card reads a URL and a score, what it links to and what it leaves to the list around it.

- **Source line:** The host loses a leading www., the path shows unless it is just a slash, and the query string and hash are dropped. A value that is not a valid URL, such as docs/install, shows as given.
- **Link safety:** The title links only for http(s) URLs and relative paths, and other schemes such as javascript or data show as plain text. Links open in a new tab and withhold the opener.
- **New tab:** Nothing in the link tells a screen reader that it opens a new tab. If that matters, say so in the text around the list.
- **Relevance:** A value up to 1 is a fraction and anything above is a percentage, rounded: 0.944 and 94.4 both read 94% match. The value is not clamped, so pass a real number or none.
- **Selected:** Selected switches the border to primary, the fill to subtle and the badge to indigo. Hover changes nothing, because the card is not a control.
- **No images:** The card shows no favicon and makes no request of its own. The icon beside the host is a fixed link icon.
- **Long content:** Nothing is shortened: the title and snippet wrap, and a long path breaks at any character. To clamp the snippet, wrap it in a span with a two-line clamp.
- **States of the list:** Loading, no results and a failed search are not card states. Build them from Skeleton, Empty State and Alert where the list goes, and mark the list busy while the search runs.
- **Motion:** None. The title underlines on hover, and there is no animation to switch off.
- **Reduced motion:** Reduced motion changes nothing.

## Anatomy

- `SearchResultCard`: An article with a 1 px border, 16 px radius and 16 px padding. A selected result gets the primary border and the subtle fill.
- `Rank`: A 22 px circle with the position of the result, shown when a rank is set. It sits on the subtle fill, or on the card colour when selected.
- `Source line`: A link icon, the host without www. in medium text and the path in tertiary text. The query string and the hash are left out.
- `Relevance badge`: A light Badge reading 94% match, shown when a relevance is set. Grey normally, indigo on a selected result.
- `Title link`: The title in semibold link colour. It opens in a new tab, and only for http(s) URLs and relative paths.
- `Snippet`: 13 px secondary text under the title, any content you pass. It is not shortened, and an empty snippet is not rendered.
- `SearchResultRow`: One search hit as a row, for a result list or a command palette: a 40 px icon tile in the indigo tint, a title, a two-line excerpt, where the hit lives and a chevron. With `href` it is a link, without it a button. It replaces SearchResult.
- `SearchResult`

## Best practices

### When to use

- Use it for what a search tool returned. For sources pinned under a final answer use Source List, and for a source cited inside a message use Chat Source.

### Do

- Pass the full URL with its scheme, so the card can show host and path and people can judge the source before opening it. A relative path of an internal search works too.
- Put the cards in a list with one item per card. The card is an article without a name of its own.
- Mark the cited result as selected and say it in words too, for example The answer cites result 2 in a status line. The card sets no ARIA state for selection.
- Highlight the words of the query with mark and keep the snippet as text. It comes from the web, so never pass it as HTML.
- Show a running, empty or failed search in the list itself, with a Skeleton, an Empty State or an Alert, and announce it in a status line.

### Don't

- Don't invent a relevance score. Pass one only when the tool provides it, or the badge claims a precision that does not exist.
- Don't pass 1 to mean 1%, because values up to 1 are fractions and 1 reads 100% match. Use 0.01 for one percent.
- Don't add a favicon from a third-party service. It tells that service what the agent searched for, so the card leaves it out on purpose.

## API reference

### SearchResultCard

| Prop | Type | Default | Description |
|---|---|---|---|
| title* | React.ReactNode |  | The text of the link. Any content; it wraps and is never shortened. |
| url* | string |  | The address of the page. The card shows its host and path and links to it when it is http(s) or a relative path. Any other scheme is shown as plain text. |
| cited | boolean | false | The agent used this result in its answer: shows a "Cited" badge. |
| className | string |  | Extra classes for the card, for example a maximum width. It is `w-full` by default. |
| onSelect | () => void |  | Makes the whole card a button, for example to open the source in a side panel. The title is then text, not a link. |
| rank | number |  | The position of the result, shown in a circle before the source line. Leave it out for an unordered list. |
| relevance | number |  | The match score. 0 to 1 is a fraction and above 1 a percentage, rounded and written as `94% match`. Hidden when not set. |
| selected | boolean | false | Marks the result the agent cited: primary border, subtle fill, indigo badge and `data-selected`. It sets no ARIA state, so say it in text as well. Default `false`. |
| snippet | React.ReactNode |  | The text under the title. Any content, so it can hold `<mark>` for the words of the query. An empty value renders nothing. |

### SearchResult

| Prop | Type | Default |
|---|---|---|
| title* | React.ReactNode |  |
| className | string |  |
| description | React.ReactNode |  |
| href | string |  |
| icon | React.ReactNode |  |
| meta | React.ReactNode |  |
| onSelect | () => void |  |

### SearchResultRow

| Prop | Type | Default | Description |
|---|---|---|---|
| title* | React.ReactNode |  | The name of the hit. Required. |
| className | string |  | Extra classes on the row. |
| description | React.ReactNode |  | A short excerpt under the title, cut after two lines. |
| href | string |  | Makes the row a link. Without it the row is a button, so nothing jumps to `#`. |
| icon | React.ReactNode |  | The icon in the tile. A document icon when left out. |
| meta | React.ReactNode |  | Where the hit lives and when it changed, in 11 px tertiary text, such as `Reports · Oct 28`. |
| onSelect | () => void |  | Called when the row is pressed, also on a link. |

## Examples

### Source: what the source line makes of a URL

### Snippet: plain, highlighted, clamped or left out

### Meta: the rank and the match badge

### List state: results, loading, no results, failed

### Result row: a hit with an icon, a title and an excerpt

### Select: a button card and a cited badge

## In context

### Tool call: ranked results and the one the answer cites

The results of a web search in a list. The segment moves the citation, the card marks the cited result with a border and fill, and a status line names it.

### Live search: loading, results, no results and a failure

Search for a word to see a skeleton while it runs, then matches with the query highlighted. No match shows the empty state, and typing timeout fails once so you can try Try again.

## For AI agents

`get_component("search-result-card")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
