suiss/ui ยท AI
Sources
The links the agent used for a reply, in a row that opens into a list of links.
Sources is a row that lists the links the agent used for a reply. It says how many there are, such as "Used 3 sources", and opens into a link for each one.
The list is a TraceCollapsible with a nested Trace of links. To cite a source inside a sentence, use Inline Citation.
Installation
Sources is built with the Trace component.
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
AI SDK
Collect the source-url parts of a message and render them after the text. The agent can cite the same page more than once, so dedupe them by url.
title is optional on a source-url part. Fall back to the hostname of the URL.
Accessibility
- Each source is a plain link inside the list.
- Links open in a new tab. Add
sr-onlytext, such as "(opens in a new tab)", so screen readers announce it. - The arrow icon is decorative, so the title is the name of the link.
- The count in the trigger, such as "Used 3 sources", says what opens before the list is opened.
API Reference
See Trace for every part and prop.
Web preview
This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
Sources on mobile is built from the same parts as on the web: Trace, Message, Bubble. The example above is a static demo; connect it to your agent by rendering the same parts from your messages.