Components/ContextCards

ContextCards

A card list of retrieved RAG chunks and their sources.

VerifiedSince 0.3.9

Usage

Basic

Cards fade up in sequence and source chips follow; staggerStep, chipDelay, and chipStaggerStep set the timing.

Loading demo...

Single Card

TxContextChunk renders one card for hosts that lay out their own list; standalone use usually turns appear off.

<TxContextChunk :chunk="chunk" :appear="false" @open="openSource" />

Best Practices

  • Pass the corpus size as total and the actual hits as chunks, so "2 of 32" is visible at a glance.
  • Format chars host-side, thousands separators included; the component does no number localization.
  • Set appear to false for long lists; past a dozen cards, sequenced entrances feel sluggish.
  • Map tone to file format consistently (red for PDF, green for CSV), not by card order.

API Reference

TxContextCards

Props

PropTypeDefaultDescription
chunksContextChunk[]-The chunk list.
titlestring'All chunks'Header label.
totalnumber | string-Header count: the corpus size, not chunks.length. Omit to drop it.
appearbooleantruePlays the entrance; turn it off for lists that re-render often.
staggerStepnumber100Gap between card entrances, in ms.
chipDelaynumber700Delay before the first source chip, in ms.
chipStaggerStepnumber80Gap between source chips, in ms.

Events

EventPayloadDescription
openContextChunkOpenPayloadFires when a source row is activated; opening it is the host's call.

Slots

SlotPropsDescription
header-Replaces the header row.
chunk{ chunk, index }Replaces a whole card.
chunk-title / chunk-body / chunk-sourceas in TxContextChunkForwarded to TxContextChunk's title / body / source slots.

TxContextChunk

Props

PropTypeDefaultDescription
chunkContextChunk-A single chunk.
appearbooleantruePlays the entrance.
enterDelaynumber0Absolute delay before the card fades up, in ms.
chipDelaynumber700Absolute delay before the source chip appears, in ms.

Events

EventPayloadDescription
openContextChunkOpenPayloadFires when the source row is activated.

Slots

SlotPropsDescription
title{ chunk }Replaces the title text.
body{ chunk }Replaces the body.
source{ chunk, source }Replaces the source row.

Types

NameDescription
ContextChunk{ id, title, body?, chars?, source? }; chars is a pre-formatted string such as 290 characters.
ContextChunkSource{ name, badge?, tone?, href? }; tone reuses IconChipTone.
ContextChunkOpenPayload{ chunk, source }.

Overview

  • A source with an href renders as an <a> that keeps it; a click calls preventDefault() and emits open, matching TxSources. Without an href it is a static <span> with no hover feedback.
  • Chunks appended after mount skip the stagger, so they never wait on their index.
  • Under reduced motion the delays drop to zero and source chips show at once.
  • Entrances play only when an element is created; replaying means remounting (a new key).

Technologies

  • The child exports only as TxContextChunk, with no unprefixed alias: ContextChunk is the data type's name.
  • Adapted from Beautiful UI (© 2026 Shane Levine, MIT).
  • Source: packages/tuffex/packages/components/src/context-cards/.
查看源码
packages/tuffex/packages/components/src/context-cards/index.ts