Context cards

A React component in Beamline's AI & agents category.

The knowledge an agent retrieved before it answered: one card per chunk with what it is about, the text it read with the search words marked, how relevant it was and where it came from, filterable by source; optionally each chunk can be left out of the next answer.

Use it for

  • Showing what a retrieval step found, so people can judge an answer's grounding.
  • Letting people leave a retrieved chunk out and ask again.

Not for

  • Numbered citations inside the answer text (citations).
  • Files the person attached (attachment).
  • A search results page (a list of item rows).

Anatomy

  • header: label, "8 chunks from 5 sources · n used in the answer" (the count fades to its new value)
  • source filter (chip group, All + one per source with counts; folds into +N by room)
  • card: title, relevance meter (segments + word, hatched when none) beside the title while both fit and under it when they do not, text with search words marked (a tint that never splits a word), Show more
  • source line: type glyph (or connector icon), name (link, cut with the full name on hover), location; the Use in answer check sits at its end and wraps under it in a narrow card
  • Use in answer check (when selectable)
  • room: the region is a size container; cards sit one per row, two across from 42rem of room and three from 72rem; under 20rem a card's padding tightens

Variants

  • layout: grid (one column, two from 42rem of its own width, three from 72rem), list (always one column, for side panels)

States

  • loading (skeleton cards, aria-busy)
  • empty (emptyLabel)
  • filtered by source
  • text clamped / expanded
  • relevance not scored
  • left out of the answer (unchecked; title and text step down one ink, never faded below 4.5:1)

Keyboard

  • Arrow keys choose the source filter (radio group)
  • Show more / Show less is a button with aria-expanded
  • Source names are links; Use in answer is a checkbox

Motion

Show more and Show less ease the text's height between its clamp and its full length (useHeightMorph). A source filter keeps each card's identity: cards that stay slide to their new places and returning ones grow in (useFlip). The used count fades to its new value; a card left out steps its ink down over --pui-motion-out; a relevance change lights or lets go of its segments one after another. The filter chips animate their own check (ChipGroup). Reduced motion places at once.

Props

PropTypeDefaultDescription
chunks (required)ContextChunk[]—Retrieved text chunks to inspect or include. Required.
querystring—What was searched; matching words are marked in the text.
selected / defaultSelected / onSelectedChangestring[]—selected: Chunks used in the answer, controlled or not. Giving any of these adds a "Use in answer" check to each card. defaultSelected: Initially included chunk ids; defaults to every supplied chunk when selection is enabled. onSelectedChange: Reports selected ids after a change; no callback by default.
onOpenSource(chunk) => void—Called when a source is opened (in addition to following its url).
layout / previewLines"grid" | "list" / number—layout: grid: cards side by side (default); list: one per row for side panels. previewLines: Lines of text before "Show more". Default 4.
loading / emptyLabel / labelboolean / ReactNode / string—loading: Shows the loading state while data or an operation is pending. Defaults to false. emptyLabel: Said when nothing was retrieved. label: The region's heading. Default "Retrieved context".
style / refCSSProperties / native Ref—style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default.
classNamesContextCardsClassNames—Classes for the named visual parts; no part overrides by default.
styleCSSProperties—Inline styles on the documented visual root; no inline overrides by default.
labelstring—The region's heading. Default "Retrieved context".
selectedstring[]—Chunks used in the answer, controlled or not. Giving any of these adds a "Use in answer" check to each card.
defaultSelectedstring[]—Initially included chunk ids; defaults to every supplied chunk when selection is enabled.
onSelectedChange((ids: string[]) => void)—Reports selected ids after a change; no callback by default.
layout"grid" | "list"—grid: cards side by side (default); list: one per row for side panels.
previewLinesnumber—Lines of text before "Show more". Default 4.
loadingboolean—Shows the loading state while data or an operation is pending. Defaults to false.
emptyLabelReactNode—Said when nothing was retrieved.
classNamestring—Classes on the documented visual root; no override by default.
refRef<HTMLElement>—Receives the documented root element; no ref by default.

Built from

Used in

Dependencies

lucide-react, radix-ui

Import

import { ContextCards } from "@beamline/context-cards";

Get it

Context cards is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent

More in AI & agents

  • Image generation: The frame an AI image is generated into: a field of brand-hued pixels breathes with the progress while the model works, then the image arrives —…
  • Flowchart: A workflow as steps on a dotted canvas: a trigger, conditions that branch into paths side by side, actions and waits, read top to bottom; during a run…
  • Run trace: One agent run as a waterfall: every step (model calls, tools, retrieval, checks, sub-agents) nested under the step that started it, each a bar on a…
  • Run theatre: One agent run as a theatre: the Run trace's waterfall under a transport (play, scrub, speed) that replays the run as it happened. Pick a step and re-run…
  • Answer compare: Two answers to the same prompt side by side, and a person's verdict: A is better, a tie, B is better, or both are bad, with the reasons that decided it…
  • Branch navigator: The versions of an assistant conversation that forked when a message was edited or an answer regenerated: a “‹ 2 / 3 ›” switch on each message that has…
  • Response: An assistant's answer as streamed markdown in the system's reading type: bursty tokens flow in at an even pace, each new word fades in through a short…
  • Chat thread: People talking to people: messages grouped by person and day, reactions, delivery and read receipts that glide to the newest message read, who is typing…
  • Model picker: Choose the AI model for a request by what it can do and what it costs: a trigger with the model's name opens a searchable list grouped by provider, with…
  • Task rows: Background work an agent is doing, one row per task: status as a glyph and a word, what it produced, how long it has run or took, a progress bar while…
  • Conversation: The scrolling column of a conversation: follows new content while you are at the bottom, stops when you scroll up to read, and offers a way back; shared…
  • Prompt suggestions: Ready-made prompts a person can start from or follow up with: chips, cards or a list; a picked one lifts off and flies into the composer as its text…
  • Plan: An agent's plan: numbered steps with live status, progress, and Approve / Edit / Reject when it needs sign-off; approving shows progress, and a refusal…
  • Approval card: The agent stops and asks before it acts: what it wants to do, exactly what that changes, any choices it needs, and Approve or Reject; both run your…
  • Tool call: One tool call in an agent's run: status, what it did and a short result on one quiet row that opens to the exact input and output; stops for permission…
  • Recommendation card: One suggestion from the agent that the person may take or leave: what it suggests, why, the expected effect and how sure it is (a meter and a word…
  • Citations: Inline numbered citations that preview their source on hover or focus, plus a numbered source list; streamed answers flow in at an even pace with the…
  • Reasoning: The agent's trace, fed by your stream: a shimmering label and the seconds so far while it works, then "Thought for N seconds"; steps that check off…
  • Attachment: A file tile: preview or typed glyph with the type named, name, size, upload progress, error with retry, and a keyboard-reachable remove.
  • Prompt bar: The agent composer: a field that grows, @ to add a source, / for a command, a model picker, files and dictation, and one button that sends with progress…
  • Selection actions: Select a passage and hand it to the agent: a bar over the selection with quick actions, your own instruction and More; while the agent works it says so…
  • Message: One turn in a conversation with an agent: the person's words in a quiet bubble, the agent's answer on the page with its orb mark, trace, tool calls and…

Part of Beamline UI: polished, editable React components and complete screens for custom applications. Build your own style from any look; tokens, fonts, radii, motion; not only colours.