StealThis .dev

RAG Source Panel

A retrieval-augmented answer with inline citation chips that spotlight matching source cards in a filterable, score-sortable side panel — hover or click a citation to scroll and highlight its evidence, complete with snippet, title, relevance score and URL.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

The RAG Source Panel pairs a generated answer with the evidence behind it. The answer text carries inline citation chips like [1] and [2]; hovering or clicking one spotlights the matching source card in the panel on the right, scrolling it into view and pulsing a highlight ring. Hovering a source card works the other way too, lighting up every citation that points at it, so the link between claim and evidence is always visible in both directions.

Each source card shows a snippet, document title, a color-coded relevance score bar, and a clickable URL. The panel header exposes a live filter (minimum score threshold) and a sort toggle (by relevance or by document order), letting you triage which sources actually mattered. A running count updates as you filter, and keyboard focus moves cleanly through chips and cards with visible focus rings.

Interaction-wise the component leans on plain DOM APIs: Element.scrollIntoView({ behavior: "smooth", block: "nearest" }) for the scroll-to-source behavior, IntersectionObserver to fade in cards as they enter the panel viewport, and delegated pointer/focus events to keep the citation ↔ source cross-highlighting in sync. Everything is vanilla JS with a graceful fallback when smooth scrolling or IntersectionObserver is unavailable.