Source
A small link chip with a favicon and a label for a page the model searched, read, or cited. Use it in a reasoning step to show what was read, or inline after a claim with a card that previews the cited pages.
Installation
Copy the command below and run it in your terminal.
Usage
Root is a link, so href is required. Absolute
http and https links open in a new tab unless you set target. Icon shows the favicon from src, which can be any image URL, such as
one your search backend returns, and Label truncates long names.
Citations
Place Root inside the paragraph, right
after the sentence it supports. There the chip tightens to sit on the text line. Add a Content and the chip opens it on hover and focus. Put one Item in it per cited page, each with an Icon, Label, Title, and an optional Description. Content renders only in the
browser, so it is safe inside a <p>.
Examples
Missing icons
When src is missing or fails to load,
the icon shows the first letter of fallback, or a globe without one.
Inline citation
Hover or focus the chip to preview the cited page.
People notice a delay after about a second and lose focus after ten, so a model that reasons for several seconds needs feedback that changes. Nielsen Norman Group
Multiple sources
Set count on Root to the number of cited pages, and Count shows how many follow the first, such as +1. Count reads the prop, because the
card's items are not mounted until it opens.
Drive the motion from the browser’s frame loop so the indicator and the text stay smooth without blocking input. MDN and 1 more source
Anatomy
Source.Root - Links to the page as a compact chip and holds the hover state and count.
Source.Icon - Shows the favicon or a fallback.
Source.Label - Renders the truncated site name.
Source.Count - Shows how many sources follow the first.
Source.Content - Opens a hover card of the cited pages.
Source.Item - Links one cited page and lays out its parts.
Source.Title - Renders the page title.
Source.Description - Renders a two-line excerpt.
<script lang="ts"> import * as Source from '@sivir-ui/svelte/components/source'; const sources = [ { domain: 'nngroup.com', href: 'https://www.nngroup.com/articles/response-times-3-important-limits/', icon: '/favicons/nngroup.com.png' }, { domain: 'developer.mozilla.org', href: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame', icon: '/favicons/developer.mozilla.org.png' }, { domain: 'web.dev', href: 'https://web.dev/articles/optimize-inp', icon: '/favicons/web.dev.png' } ]; </script> <div class="flex max-w-xl flex-wrap gap-1.5"> {#each sources as source (source.href)} <Source.Root href={source.href}> <Source.Icon src={source.icon} fallback={source.domain} /> <Source.Label>{source.domain}</Source.Label> </Source.Root> {/each} </div>