Skip to content
DocsStar33Playground

Vue Drop-in Blocks

How-to guideUnstableLast updated 2026-12-03 · da74202ecQuickstart

@reactive-agents/vue/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 Vue. For what each block does, read the Svelte pages: Drop-in UI Blocks and Context Window Views and Markdown. The React equivalent is React Drop-in Blocks.

The blocks own no store and make no request. Props go down, events come up; you perform the decision and pass busy and error back. They are plain defineComponent render functions, so the package needs no SFC loader and its root stays plain TypeScript. A conformance test renders each block in Svelte and in Vue for the same input and compares structure, hooks and aria.

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.

Terminal window
bun add @reactive-agents/vue
# or: npm install @reactive-agents/vue

Vue 3.2 or later. Import the stylesheet once, at the app root, then import blocks from the ./components subpath:

import "@reactive-agents/vue/styles.css";
import { ApprovalCard, Composer, Toaster, createToaster } from "@reactive-agents/vue/components";
Subpath Holds
@reactive-agents/vue The streaming composables (useAgentStream, useAgent, useStructuredObject) and, from 0.20.1, the durable-run composables (useRun, useResumableRun and four more)
@reactive-agents/vue/components The drop-in blocks on this page
@reactive-agents/vue/markdown Markdown, renderMarkdown, sanitizeMarkdownHtml, decorateRendered (optional peers, below)
@reactive-agents/vue/styles.css The --ra-* token sheet plus the block rules
Group Exports from /components
Run control ControlButton, ContinueStopped
Chat input Composer, SlashMenu
Human in the loop ApprovalCard, ApprovalParams, QuestionCard, QuestionReply, QuestionForm
Run evidence ReceiptCard
Settings form ConfigSection, FieldRow, ListField
Overlays and lists VirtualList, Tooltip, vTooltip, withTooltip, Toaster, createToaster, provideToaster, useToaster
Context views ContextGauge, ContextChart, ContextAttribution, ContextFindings
Primitives and icons RaButton, RaIcon, RaStatus, provideIconRegistry, useIconRegistry

The index also exports the shared defaults (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.

Svelte Vue
Callback props (onContinue, onRetry, onApprove, onDeny, onReply, onToggle, onselect) Emits: @continue, @retry, @approve, @deny, @reply, @toggle, @select
onHide and onDismiss @hide and @dismiss (see below)
Snippets Slots with the same names; arguments arrive as the slot’s scope (#header="{ approval, heading }")
bind: on the composer text and caret v-model and v-model:caret on Composer; v-model:draft on ListField
use:tooltip action v-tooltip directive (vTooltip), withTooltip for render functions, or the Tooltip wrapper
setToaster / getToaster provideToaster / useToaster (call from setup)
setIconRegistry / getIconRegistry provideIconRegistry / useIconRegistry (call from setup)
ControlButton iconSnippet icon slot (the icon prop is the icon id)

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. Use class as usual; Composer also takes boxClass.

One block keeps a callback: ListField takes onAdd as a prop, not an event, because an event cannot return a value. onAdd(text) may return false to reject the text and keep it in the box. Removal is the remove event with the index.

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.

<script setup lang="ts">
import { watchEffect } from "vue";
import { createComposer } from "@reactive-agents/ui-core";
import { Composer } from "@reactive-agents/vue/components";
const props = defineProps<{ running: boolean }>();
const composer = createComposer({
commands: [{ name: "clear", summary: "Start a new chat" }],
onSend: (text) => startRun(text),
onStop: () => stopRun(),
});
watchEffect(() => composer.setSending(props.running));
</script>
<template>
<Composer :composer="composer" />
</template>

startRun and stopRun are your own functions.

Controlled. Use v-model for the text and v-model:caret for the caret offset. Pass sending, queued, sendAction and the menu state (menuOpen, menuIndex, menuItems), and handle the events submit, stop, menuMove, menuPick, menuClose, clearQueued, sendQueuedNow, menuHover and menuDismiss. The files event receives files dropped on or pasted into the box. The shortcut prop is a function that runs first on every key press; return true when it handled the key. The component exposes inputEl (the textarea) and focus() on a template ref.

<Composer v-model="text" :sending="running" @submit="send(text)" @stop="stop" />

Slots: leading, attachments, banner, belowField, footerStart, hint, actions, trailing, emptyMenu.

ApprovalCard takes approval and emits approve and deny (with the reason, or undefined when left blank). QuestionCard takes question and emits reply (with the value) and invalid. Both take busy, error and labels.

<ApprovalCard :approval="approval" :busy="busy" @approve="approve" @deny="(reason) => deny(reason)" @hide="hide" />

Dismiss means one of two things, and the listener you attach picks which:

  • @hide only takes the card off the screen. The approval or question stays pending elsewhere.
  • @dismiss is a decision the host sends. The card shows busy="dismiss" while it is on its way.

A card shows Dismiss only when the host listens to one of them. With both, dismiss wins. The rule is cardDismissKind in ui-core, the same in all three bindings; Vue finds the listener with a presence check, so a listener you attach changes the card’s buttons.

ReceiptCard draws the trust receipt of a finished run. It takes receipt, signature, redacted, noneReason and labels, and emits copy with the raw JSON. With no @copy listener the card writes the JSON to the clipboard itself; a listener replaces that write. 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.

ControlButton takes kind (pause, stop or terminate) and pending; attach @click (it goes to the button). The escalation slot renders after the button while that control is pending. ContinueStopped takes kind, stop, busy and error, emits continue (with the body) and retry, and has the slots header, actions and icon.

VirtualList takes items (each with a stable key) and label; the item slot renders a row and receives { item, index }. Call scrollToIndex(i) on a template ref to bring a row into view.

<VirtualList ref="list" :items="rows" label="Runs">
<template #item="{ item }"><RunRow :row="item" /></template>
</VirtualList>

The tooltip is a directive: <button v-tooltip="'Delete run'">. Register it with app.directive("tooltip", vTooltip), or import vTooltip in <script setup>. Tooltip wraps a target that takes no directive; its props are text, placement, enabled and disabled.

The toaster is a store you create. Share it from a parent’s setup, or pass it as a prop:

import { createToaster, provideToaster } from "@reactive-agents/vue/components";
const toaster = createToaster();
provideToaster(toaster); // in setup; then <Toaster /> below renders it
toaster.success("Saved");

Toaster renders its toaster prop, or the provided one, and renders nothing with neither. bottom, side, the icon slot (receives the toast) and the item slot (receives { toast, dismiss }) customise it.

ConfigSection takes id, open and title, emits toggle, and has the slots head and default. FieldRow takes label, for, description and wide, with the slots help and control. ListField takes id, items, onAdd, issues, variant, suggestions and v-model:draft; its slots are item, empty, draftExtras and below.

ContextGauge takes events or a ready pressure. ContextChart takes timeline and selectedId and emits select. ContextAttribution takes attribution and ranked. ContextFindings takes findings and emits inspect. You map your own records to the ui-core view models (attributeContext, contextTimeline, contextFindings), as described in Context Window Views and Markdown.

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 provide one for a subtree from setup:

import { RA_DEFAULT_ICONS, provideIconRegistry } from "@reactive-agents/vue/components";
provideIconRegistry({ ...RA_DEFAULT_ICONS, check: "<svg>...</svg>" });

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:

Terminal window
bun add marked dompurify
<script setup lang="ts">
import { Markdown } from "@reactive-agents/vue/markdown";
</script>
<template>
<Markdown :markdown="reply" @copy="(r) => notify(r.ok)" />
</template>

Props: markdown, showCopy, codeCopy, headingIds, math, render, icons, labels. Events: rendered (with the container, after each render) and copy (with { kind, ok }). Sanitising is always on, with the same allow-lists and link policy as the Svelte binding: scripts, images, frames, forms, class, style and on* attributes never reach the page, and links keep href only for http(s), mailto and in-page anchors. 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.

From 0.20.1 the package root exports composables for durable runs: a run that pauses on an approval gate or a question, survives a page reload and can be picked up again. They need Vue 3.2 or later (the package’s vue peer range is >=3.2.0). Each is a thin reactive wrapper over @reactive-agents/ui-core and takes the same option names as the React hook of the same name.

Composable Options Returns
useRun endpoint, fetchImpl?, objectMode?, auto?: { prompt, body? }, attach?: { runId, cursor? } state (a read-only ref of the ui-core RunState), run(prompt, body?), cancel(), reattach(runId, cursor?)
useResumableRun endpoint, runId, cursor?, fetchImpl?, objectMode? The same as useRun; it reattaches to runId once mounted
useInteractions interactionEndpoint, fetchImpl? respond(runId, interactionId, value), plus the read-only refs pending and error
useTaskInbox endpoint, fetchImpl?, pollMs? Read-only refs runs, loading and error, plus refresh()
useRunCost(state) The state ref, a getter or a plain RunState A computed { tokens, usd }
useRunSteps(state) The same A computed list of StepEntry rows

The root also re-exports the two ui-core requests that resume a waiting run: respondToInteraction answers a question (state.pendingInteraction) and decideApproval approves or denies an approval gate (state.pendingApproval). Both resolve to { success, output, error? } and do not reject on a failed request.

How they behave:

  • state is replaced whole on every stream event. The fields you will read most are status ("idle", "streaming", "awaiting-interaction", "awaiting-approval", "completed", "error" or "cancelled"), text, output, runId, lastSeq, pendingApproval, pendingInteraction, cost and error. Agentic UI Core documents the state and the stream it is built from.
  • auto and attach start after the component mounts, so a server render opens no stream. attach wins when both are set.
  • The stream is aborted when the component (or the effect scope that called the composable) is disposed. cancel() aborts the stream and sets the status to "cancelled"; it does not stop the run on the server.
  • useTaskInbox fetches once after mount, then every pollMs milliseconds when you set it. A failed refresh keeps the last list and sets error.

Example: approve a tool call, and reattach after a reload

Section titled “Example: approve a tool call, and reattach after a reload”

This is the body of a <script setup lang="ts"> block. It starts a run, shows a pending approval, sends the decision with decideApproval and reattaches to the run so the rest of the stream arrives. The run id is kept in localStorage, so a reload in the middle of the run (or while it waits on the approval) reattaches with useResumableRun.

import { ref, watch } from "vue";
import { decideApproval, useResumableRun, useRun, useRunCost } from "@reactive-agents/vue";
const endpoint = "/api/agent";
const saved = localStorage.getItem("runId");
// After a reload, reattach to the saved run. Otherwise wait for run().
const { state, run, reattach } = saved ? useResumableRun({ endpoint, runId: saved }) : useRun({ endpoint });
const cost = useRunCost(state);
const failure = ref<string | null>(null);
watch(
() => [state.value.runId, state.value.status] as const,
([runId, status]) => {
if (status === "completed") localStorage.removeItem("runId");
else if (runId) localStorage.setItem("runId", runId);
},
);
const decide = async (decision: "approve" | "deny", reason?: string) => {
const gate = state.value.pendingApproval;
if (!gate) return;
const result = await decideApproval({
endpoint: "/api/approval",
runId: gate.runId,
gateId: gate.gateId,
decision,
reason,
});
if (!result.success) {
failure.value = result.error ?? "The decision was not sent.";
return;
}
// The stream ended when the run paused. Reattach to follow the resumed run.
reattach(gate.runId, state.value.lastSeq);
};
<template>
<button :disabled="state.status === 'streaming'" @click="run('Write the summary to notes.md')">Run</button>
<p style="white-space: pre-wrap">{{ state.text }}</p>
<div v-if="state.status === 'awaiting-approval' && state.pendingApproval">
<p>Allow {{ state.pendingApproval.toolName }}?</p>
<button @click="decide('approve')">Approve</button>
<button @click="decide('deny', 'Not now')">Deny</button>
</div>
<p v-if="failure">{{ failure }}</p>
<small>{{ cost.tokens }} tokens</small>
</template>

/api/agent and /api/approval are your own routes. /api/agent must serve a durable run: POST starts one and GET /api/agent/<runId>?cursor=N replays the events after N. Durable Human-in-the-Loop covers the server side: the approval policy, the durable store and approving or denying from any process. To draw the approval with the drop-in block in place of the two buttons, pass the pending approval to ApprovalCard (above). For a question, call respond from useInteractions with state.pendingInteraction.

The Vue bindings are unstable: signatures can change in a minor release, so pin a version. See Stability.

Install

Bun (recommended)bun add reactive-agents
Node 22.5+npm install reactive-agents

Get notified on new releases

Release notes, about once a month.