Skip to content
WunderUI

Chat Source

Pro

A compact card for one source an answer cites: a number, the page title and the host.

Playground

Installation

Chat Source comes with WunderUI Core and Pro, in the package from your plan. See the plans.

Then import what you need:

tsx
import { ChatSource } from "@wunderui/react"

Then use it:

tsx
import { ChatSource } from "@wunderui/react"

export function Cited() {
  return <ChatSource index={1} title="Q3 revenue report" domain="wunderui.com" href="https://wunderui.com" />
}

Expected result: You see a small card with the number 1 in a grey circle, a globe, the title Q3 revenue report and wunderui.com under it. Press it and the address opens in a new tab.

When to use

Use Chat Source for

  • A source an answer cites, with the number of its citation
  • A link to the page or document an answer comes from
  • A short row of sources under a finished reply

Use something else for

  • Source List for a numbered, pinned list of all the sources of an answer
  • Chat Attachment for a file the person attached, not a page the answer cites
  • Chat Message for the bubble that holds the answer and the citations in its text

Content

Title and host are one line each and cut off at the end. Show the host, not the whole address, and give the card a width.

Layout

The card is one source with no group around it. Put several in a named list so a screen reader says how many, and let the row wrap.

Newer props

Pass icon for a pull request or file, active for the source a citation points at, and leave out href to get a button for an in-page action.

Own icon, active source, button without a link

Keyboard interactions

The card is a native link, so the browser handles focus and activation.

TaborShiftTab
Moves focus to the next or previous source. Focus shows as an indigo border with a 2 px ring.
Enter
Follows the link: opens the address in a new tab, or, with the default , calls and stays on the page. A link does not react to Space.

Behavior and motion

What the card does with its link, its text, assistive technology and motion.

Link
A real address opens in a new tab with no referrer, and the click handler runs before the page opens. With the default placeholder it prevents navigation, so the page does not jump to the top.
Name
The accessible name is the text inside the link: the number, the title and the domain, in that order. There is no extra label and no hint that the link opens a new tab.
Numbering
The number is text inside the card and does not find the marker in your answer. Write the marker in the text yourself and keep the two numbers in step.
Truncation
The title and the domain stay on one line each and are cut at the end. The card takes the width it is given, so a flex child needs a maximum width or a column to truncate in.
Live region
The card is not a live region. When sources arrive after the answer, add a status line that counts them, in the page before it has text.
States
Hover fills the card with the page tone and pressing with the subtle tone. Focus is an indigo border with a 2 px ring.
Motion
None. Colours change at once and nothing moves, so there is nothing to reduce.

Anatomy

The figure marks the card and its parts. The number is left out when no citation number is given.

  • A link drawn as a card with a 1 px border and an 8 px radius. A real address opens in a new tab, while the default placeholder only calls the click handler.

  • Optional

    A 16 px round badge with the citation number in 10 px semibold text. It is left out without a number.

  • A 14 px globe in the tertiary text colour. It is always drawn.

  • The title in 12 px medium text, on one line and cut at the end.

  • The domain in 11 px tertiary text, on one line and cut at the end.

Best practices

  • Do

    Give the card the same number as the citation in the answer text, so a reader finds the source. The card draws the number, and the marker in the text is yours.

  • Do

    Pass the real address. It opens in a new tab with no referrer and no access to your window, while the default placeholder only calls the click handler.

  • Do

    Put several sources in a list with an accessible name such as Sources, so a screen reader announces how many there are.

  • Do

    Give the card a width to truncate in, such as a maximum width in a wrapping row. Without one, a long title makes the card as wide as the line.

  • Don’t

    Don't put a full URL into the domain. Pass the host, such as wunderui.com, and the page name as the title, and both are cut to one line.

  • Don’t

    Don't count on the card to say that it opens a new tab. A screen reader reads only the number, title and domain, so say it in the text next to the list if it matters.

API reference

ChatSource is a plain component, so this table lists every prop.

A link drawn as a card with a 1 px border and an 8 px radius. A real address opens in a new tab, while the default placeholder only calls the click handler.

PropTypeDefaultDescription
title requiredstring—The name of the page or document, one line, truncated at the end.
domain requiredstring—The host of the source, such as , one line, truncated at the end. Not a full address.
indexnumber—The number of the citation, drawn in a round badge. Leave it out for a source without a number.
hrefstring—Where the source lives. A real address opens in a new tab with ; the default does not navigate and only calls .
onClick() => void—Called when the card is pressed, also when is real. Use it to open the source in a panel or to mark the sentence it backs.
classNamestring—Extra classes for the card, for example so a long title truncates in a wrapping row.
activebooleanfalseMarks the source a citation in the answer points at right now.
iconReactNode—Replaces the globe, for example a pull-request or file icon. Pass the element, it is sized to 14 px.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("chat-source")
InstallIncluded in Core and Pro

The full library index for assistants is at /llms.txt.