React Drop-in Blocks
@reactive-agents/react/components ships the same block set as @reactive-agents/svelte/components. The Svelte, React and Vue blocks share one token sheet (the --ra-* variables) and one set of view models in @reactive-agents/ui-core, so a prop, a label, a data-ra-* hook, a role and an aria attribute mean the same thing in every binding. This page covers what differs in React. For what each block does, read the Svelte pages: Drop-in UI Blocks and Context Window Views and Markdown. The Vue equivalent is Vue Drop-in Blocks.
The blocks own no store and make no request. You pass state and callbacks; they render and report.
The examples below are minimal. They were compiled against the built packages (svelte-check, tsc, vue-tsc) when this page was last revised, though the docs build does not check them. Names your app supplies, such as startRun or rows, are yours. If one drifts, the exports win.
Install and import
Section titled “Install and import”bun add @reactive-agents/react# or: npm install @reactive-agents/reactReact 18 or newer. Import the stylesheet once, at the app root, then import blocks from the ./components subpath:
import "@reactive-agents/react/styles.css";import { ApprovalCard, Composer, Toaster, createToaster } from "@reactive-agents/react/components";| Subpath | Holds |
|---|---|
@reactive-agents/react |
Hooks (useRun, useInteractions, …), the headless components and the generative-UI surface (see Web Integration) |
@reactive-agents/react/components |
The drop-in blocks on this page |
@reactive-agents/react/markdown |
Markdown, renderMarkdown, sanitizeMarkdownHtml, decorateRendered (optional peers, below) |
@reactive-agents/react/styles.css |
The --ra-* token sheet plus the block rules |
The existing headless ApprovalGate and AgentPrompt stay exported but are marked @deprecated in favour of ApprovalCard and QuestionCard.
Blocks
Section titled “Blocks”| Group | Exports from /components |
|---|---|
| Run control | ControlButton, ContinueStopped |
| Chat input | Composer, SlashMenu, useComposerState |
| Human in the loop | ApprovalCard, ApprovalParams, QuestionCard, QuestionReply, QuestionForm |
| Run evidence | ReceiptCard |
| Settings form | ConfigSection, FieldRow, ListField |
| Overlays and lists | VirtualList, Tooltip, useTooltip, Toaster, ToasterProvider, createToaster, useToaster, useToasts |
| Context views | ContextGauge, ContextChart, ContextAttribution, ContextFindings |
| Primitives and icons | RaButton, RaIcon, RaStatus, IconRegistryProvider, useIconRegistry |
The index also re-exports the shared defaults from ui-core (DEFAULT_APPROVAL_LABELS, DEFAULT_QUESTION_LABELS, DEFAULT_LIST_FIELD_LABELS, DEFAULT_COMPOSER_LABELS, DEFAULT_CONTEXT_LABELS, RA_DEFAULT_ICONS, CONTEXT_SERIES_VAR, contextSeriesColor, fillLabel, iconMarkup) and their label types.
Parity with Svelte
Section titled “Parity with Svelte”| Svelte | React |
|---|---|
class |
className (also boxClass on Composer) |
onclick-style callbacks (onclick, onselect) |
camelCase (onClick, onSelect) |
Snippets (header, actions, icon, item, parameters) |
Render props: functions that return a ReactNode, such as header={({ approval, heading }) => ...} |
Simple snippets with no arguments (leading, banner, hint, trailing, empty, help, control) |
ReactNode props |
bind: on inputs |
Value plus change callback (value and onValueChange on Composer) |
use:tooltip action |
useTooltip(text) ref callback, or the Tooltip wrapper |
setToaster / getToaster (Svelte context) |
ToasterProvider / useToaster(); createToaster() is the same |
setIconRegistry / getIconRegistry (Svelte context) |
IconRegistryProvider / useIconRegistry() |
Labels, data-ra-* hooks, roles and aria attributes match the Svelte blocks. Every visible string is a labels prop that takes any subset of the defaults.
Composer
Section titled “Composer”Composer has two ways to drive it, as in Svelte.
Drop-in. Pass a ui-core createComposer controller. It owns the text, the queued message, the slash menu and the key handling. Create it once (module constant or useMemo), not on every render.
import { useEffect, useMemo } from "react";import { createComposer } from "@reactive-agents/ui-core";import { Composer } from "@reactive-agents/react/components";
function Chat({ running, startRun, stopRun }: { running: boolean; startRun: (t: string) => void; stopRun: () => void }) { const composer = useMemo( () => createComposer({ commands: [{ name: "clear", summary: "Start a new chat" }], onSend: startRun, onStop: stopRun }), [], ); useEffect(() => composer.setSending(running), [composer, running]); return <Composer composer={composer} />;}useComposerState(composer) returns the controller’s live ComposerState (or undefined for no controller), through useSyncExternalStore, when you need to read the text or queue outside the block.
Controlled. Pass value with onValueChange, plus sending, queued, sendAction and the menu state (menuOpen, menuIndex, menuItems), and handle onSubmit, onStop, onMenuMove, onMenuPick, onMenuClose, onClearQueued and onSendQueuedNow. onCaretChange reports the caret offset and inputRef gives you the textarea for focus. onFiles receives files dropped on or pasted into the box. onShortcut runs first on every key press; return true when it handled the key.
<Composer value={text} onValueChange={setText} onSubmit={() => send(text)} />Composer slots are ReactNode props: leading, attachments, banner, belowField, footerStart, hint, actions, trailing, emptyMenu.
Approval and question cards
Section titled “Approval and question cards”ApprovalCard takes approval, onApprove and onDeny(reason). QuestionCard takes question and onReply(value). Both take busy, error and labels; the host performs the decision and passes busy back.
<ApprovalCard approval={approval} onApprove={approve} onDeny={(reason) => deny(reason)} onHide={hide} />onHide versus onDismiss
Section titled “onHide versus onDismiss”Dismiss means one of two things, and the callback you pass picks which:
onHideonly takes the card off the screen. The approval or question stays pending elsewhere.onDismissis a decision the host sends. The card showsbusy="dismiss"while it is on its way.
With neither, the card shows no Dismiss button. With both, onDismiss wins. The rule is cardDismissKind in ui-core, the same in all three bindings.
Receipt card
Section titled “Receipt card”ReceiptCard draws the trust receipt of a finished run. It takes receipt, signature, redacted, noneReason, labels, onCopy(json) and className (ReceiptCardProps). It makes no request and checks no signature: pass the receipt and, when you checked it with verifyReceipt, the result as signature.
<ReceiptCard receipt={result.receipt} signature={verified ? "valid" : "invalid"} />Leave signature out when you have not checked: a signed receipt is then shown as signed but not checked. What the card shows, each prop and the data-* hooks are on ReceiptCard.
Run control
Section titled “Run control”ControlButton takes kind (pause, stop or terminate), pending (the run’s pending control) and onClick. Its escalation prop renders after the button while that control is pending. ContinueStopped takes kind, stop, busy, error, onContinue(body) and optional onRetry; its render props are header, actions and icon.
Lists, tooltips and toasts
Section titled “Lists, tooltips and toasts”VirtualList takes items (each with a stable key), label, and an item(item, index) render prop. Pass listRef and call scrollToIndex(i, align?) on the handle to bring a row into view.
const list = useRef<VirtualListHandle>(null);<VirtualList items={rows} label="Runs" item={(row) => <RunRow row={row} />} listRef={list} />;useTooltip(text) returns a ref callback for any element. Tooltip is a wrapper for a target that takes no ref. Both take the options of the shared tooltip (placement, enabled, disabled).
The toaster is a store you create. One per app, or one per subtree through a provider:
import { Toaster, ToasterProvider, createToaster, useToaster } from "@reactive-agents/react/components";
export const toaster = createToaster();
<ToasterProvider toaster={toaster}> <App /> <Toaster /></ToasterProvider>;
// anywhere below: const toast = useToaster(); toast?.success("Saved");Toaster renders its toaster prop, or the one in context. bottom, side, icon and item customise it. useToasts(toaster) returns the current stack.
Settings form
Section titled “Settings form”ConfigSection takes id, open, onToggle and title, with head and children. FieldRow takes label, description, and help and control nodes. ListField takes id, items, onAdd and onRemove; onAdd may return false to reject the text and keep it in the box. The entry box is uncontrolled unless you pass draft with onDraftChange.
Context views
Section titled “Context views”ContextGauge takes events or a ready pressure. ContextChart takes timeline, selectedId and onSelect. ContextAttribution takes attribution and ranked. ContextFindings takes findings, onInspect and limit. You map your own records to the ui-core view models (attributeContext, contextTimeline, contextFindings), as described in Context Window Views and Markdown.
Theming and icons
Section titled “Theming and icons”Set the --ra-* variables, documented at the top of styles.css, on any ancestor. Dark values apply under [data-ra-theme="dark"] or inside an element with a .dark class. Because the sheet is shared, one theme restyles every binding in an app that mixes them.
Icons are string ids. Pass an icons registry to one block, or wrap a subtree:
<IconRegistryProvider icons={{ ...RA_DEFAULT_ICONS, check: "<svg>...</svg>" }}> <App /></IconRegistryProvider>Markdown
Section titled “Markdown”Markdown lives on its own subpath because it needs a parser and a sanitiser. Install the two optional peer dependencies only when you use it:
bun add marked dompurifyimport { Markdown } from "@reactive-agents/react/markdown";
<Markdown markdown={reply} onRendered={(root) => track(root)} />;Props: markdown, showCopy, codeCopy, headingIds, math, render, onRendered, onCopy, icons, labels, className. Sanitising is always on: scripts, images, frames, forms, class, style and on* attributes never reach the page, links keep href only for http(s), mailto and in-page anchors, and display math renders only through a math function you pass (its output is trusted, not re-sanitised). render replaces the whole pipeline and must sanitise. Rendering needs a DOM; the server and the first paint show the raw text. renderMarkdown, sanitizeMarkdownHtml and decorateRendered are exported for use without the component.
Stability
Section titled “Stability”The React bindings are unstable: signatures can change in a minor release, so pin a version. See Stability.
Install
Bun (recommended)bun add reactive-agentsNode 22.5+npm install reactive-agentsGet notified on new releases
Release notes, about once a month.