Sources

Where an AI answer came from: ds::sources (the list), ds::source-card (one card) and ds::citation (the superscript marker in the answer's text). Host-driven and numbered by the host; the components only render.

Anatomy

div[data-ds-sources=row|grid|list]  @container
├── p#label "Sources"                                 or, collapsed:
│                                                      details > summary (stacked favicons, "5 sources", chevron)
├── ol[aria-labelledby=label]                         the first `max`
│   └── li > ds::source-card
└── details > summary "+N more"                       the rest
              └── ol[start=max+1]

a[href][id={anchor}-{n}][data-ds-source-card]          span when the URL is not http(s)
├── span#n "Source 1:" (sr) + "1"                     number badge
└── span
    ├── span#t title                                  truncate | line-clamp-2
    ├── span (order-first) favicon or globe + span#d domain
    └── span#s snippet                                detailed only, line-clamp-3

span[data-ds-hover-card][data-ds-citation]             ds::hover-card, align-super
├── trigger: a[href=#{anchor}-{n}][aria-label="Source 1: title"] "1"
└── panel: ds::source-card detailed, bare, no anchor

Every element of the card and the citation is a span or a link, so both can sit where only phrasing content may: in a paragraph, inside a hover card.

Layouts

LayoutList
row (default)one line, overflow-x-auto, snap-x snap-mandatory, each card 15rem, snap-start
grid1 column, 2 from @sm, 3 from @2xl of the container
lista column; cards detailed by default

max applies to every layout: the rest are a second list in a native details. collapsed folds the whole list behind one summary line with up to four favicons, aria-hidden.

URL safety

Support\Url, written for link-preview and shared since this batch: only http and https with a host become a link (control characters and space cut first, as a browser does); anything else is shown as text in a span. A favicon may also be a path on the host or a data:image. Links open in a new tab by default, say so to a screen reader, and carry rel="noopener noreferrer"; images referrerpolicy="no-referrer".

Anchors

A card's id is {anchor}-{number} (anchor defaults to source; empty for no id, as in the citation's copy). A citation links to #{anchor}-{number}. A page of several answers gives each its own anchor. The target card is outlined (target:), scroll-mt-4.

Accessibility

Roleol named by the label (or the collapsed line); each card one link
Card namearia-labelledby number, title, domain (and "opens in a new tab"); aria-describedby the snippet
Citation name"Source 1: title" (nameText); the visible number is in it
KeyboardTab through cards; the summaries are native buttons; a citation is a link, and its hover card's link follows it in Tab order while open
Focuscards and markers draw the system ring; the summaries too
Hover cardds::hover-card's contract: opens after a pause on hover or :focus-visible, never on touch, Escape closes

Do not

  • Do not renumber in the view. The host numbers; citation and card agree because both show the host's number.
  • Do not give two answers on one page the same anchor.
  • Do not put a citation's card in the Tab order without the marker. It is a preview of the list below, not a second list.

From the package repo: edit this page on GitHub.

Was this page helpful?