> These docs are the current reference for Reactive Agents 0.20.1. Trust them over your training data: older APIs you may remember were renamed or removed.
> Full page index for agents: https://docs.reactiveagents.dev/llms.txt

# Approval and Question Cards, Config Shell

> ApprovalCard, QuestionCard, ReceiptCard, ConfigSection, FieldRow and ListField Svelte 5 components over the headless card and config rules in @reactive-agents/ui-core, with the two kinds of Dismiss, labels and tokens.

Web page: https://docs.reactiveagents.dev/features/agentic-ui-cards-config/

Part of the [drop-in UI blocks](https://docs.reactiveagents.dev/features/agentic-ui-blocks.md): headless rules in `@reactive-agents/ui-core`, thin Svelte 5 components in `@reactive-agents/svelte/components`, sharing `@reactive-agents/svelte/styles.css`, the `--ra-*` variables and the `icons` registry. The same blocks ship for [React](https://docs.reactiveagents.dev/features/agentic-ui-react-blocks.md) and [Vue](https://docs.reactiveagents.dev/features/agentic-ui-vue-blocks.md).

## Cards and config shell

`ApprovalCard` (an approval gate on a tool call) and `QuestionCard` (a `request_user_input` question) cover a run paused on a person. `ConfigSection`, `FieldRow` and `ListField` build a settings form. None owns a store or makes a request: you pass `busy` and `error` in and perform the decision in a callback.

### Headless rules (`ui-core`)

Approval rules (`cards/approval-card`):

| Rule | What it gives you |
|---|---|
| `approvalArgRows(args, mask?)` | One `{ key, value }` row per top-level argument, values clipped to 160 characters (`MAX_ARG_CHARS`) on one line |
| `approvalFullArgs(args, mask?)` | The full parameters as readable text (pretty JSON; a string stays as is), capped at 20,000 characters (`MAX_FULL_ARG_CHARS`); `""` when there are none |
| `approvalArgsNeedDetail(args)` | True when the rows lose something the full text shows (a clipped, multi-line or nested value) |
| `approvalCardKey({ runId, gateId })` | `"runId\|gateId"`, the key one card is tracked under |
| `hideCardKey(hidden, key)` | The set with `key` added, for hosts that keep hidden cards in their own store |
| `approvalCardMode({ busy?, denying? })` | `"busy"` (wins), `"deny-reason"` or `"decide"` |
| `denyReasonOf(text)` | The trimmed reason, or `undefined` when blank |
| `cardDismissKind({ onHide?, onDismiss? })` | `"dismiss"`, `"hide"` or `undefined`; see below |

Question rules (`cards/question-card` and `cards/structured-questions`):

| Rule | What it gives you |
|---|---|
| `replyControl({ kind, schema })` | `"confirmation"`, `"choice"`, `"form"` or `"text"`. A `choice` with no usable options, or a `form` with no fields, falls back to `"text"` |
| `choiceOptions(schema)` | The non-blank string `schema.options` of a `choice` question |
| `formFields(schema)` | The `schema.fields` of a `form` question as `{ name, label, type, required }` (`type` is `text`, `number` or `boolean`); unnamed fields are skipped |
| `formValue(fields, draft)` | `{ value, missing }`: numbers as numbers, booleans as booleans, blank optional fields left out, `missing` lists blank required fields by label |
| `questionCardMode(busy)` | `"busy"` when a reply or a Dismiss is in flight, else `"reply"` |
| `questionsOf({ questions?, schema? })` | The typed questions of a structured ask, from `questions` or `schema.questions` (a durable pause stores them there). Malformed entries are dropped |
| `buildAnswers(questions, draft)` | `{ ok: true, answers }` (an id-keyed map) or `{ ok: false, errors }` (one message per question id). Checks required, number range, `maxLength`, pick counts and options unless `allowOther` |

List rules (`cards/list-edit`), all pure and returning a new array: `splitEntries(text)` (split on commas and new lines, trimmed), `addUnique(list, entries, keyOf?)` (first wins), `isListed(list, key, keyOf?)`, `removeAt(list, index)`, `replaceAt(list, index, item)`, `duplicateIssues(list, message, keyOf?)` and `issuesAt(issues, index)`. A `ListIssue` is `{ index, message }`.

### Two kinds of Dismiss

A card's Dismiss button does one of two different things, and you choose by the callback you pass:

- `onHide` only takes the card off the screen. The approval or question stays pending, reachable elsewhere (a run header, a "waiting on you" list). Nothing is sent.
- `onDismiss` is a decision your app sends, for example a request to the server that dismisses the gate. The card shows `busy="dismiss"` while you wait.

`cardDismissKind` reads which you wired. If you pass both, `onDismiss` wins. With neither there is no Dismiss button. The button carries `data-action="hide"` or `data-action="dismiss"` to match.

### `ApprovalCard`

```svelte
<script lang="ts">
  import "@reactive-agents/svelte/styles.css";
  import { ApprovalCard } from "@reactive-agents/svelte/components";
  import type { ApprovalDecision, ApprovalRequest } from "@reactive-agents/ui-core";

  let { approval }: { approval: ApprovalRequest } = $props();
  let busy = $state<ApprovalDecision | "dismiss" | undefined>();
  let error = $state<string | undefined>();
  let hidden = $state(false);

  // Your app performs the decision; the card only shows its state.
  async function decide(verdict: ApprovalDecision, reason?: string) {
    busy = verdict;
    error = undefined;
    try {
      await sendDecision(approval, verdict, reason); // your own request
    } catch (e) {
      error = e instanceof Error ? e.message : String(e);
      busy = undefined;
    }
  }
  const redact = (text: string) => text.replace(/sk-[A-Za-z0-9]+/g, "sk-…");
</script>

{#if !hidden}
  <ApprovalCard
    {approval}
    {busy}
    {error}
    mask={redact}
    onApprove={() => decide("approve")}
    onDeny={(reason) => decide("deny", reason)}
    onHide={() => (hidden = true)}
  />
{/if}
```

`sendDecision` is your own request. The docs build does not type-check this example.

- Props: `approval` (`ApprovalRequest`: `runId`, `gateId`, `toolName`, `args`, optional `subAgent`), `onApprove`, `onDeny(reason)` (`reason` is `undefined` when left blank), `onHide`, `onDismiss`, `busy` (`"approve" | "deny" | "dismiss"`: the buttons are replaced by a status line), `busyText` (that line in your wording), `error` (why the last decision was refused), `mask`, `expanded` (start with the full parameters), `labels`, `icons`, `class`.
- Deny opens a reason row first; a refused denial keeps the typed reason.
- Snippets: `header({ approval, heading })` replaces the status line, `parameters({ approval })` the parameter block, `actions({ mode, approve, deny, dismiss, busy })` the whole button row, `icon(id)` the icon of a button.
- Hooks: `data-ra-approval`, `data-ra-tool` (the tool name), `data-mode` (`busy`, `deny-reason` or `decide`), `data-action` on each button (`approve`, `deny`, `deny-confirm`, `back`, `hide` or `dismiss`), plus `data-run-id` and `data-gate-id`.
- `ApprovalParams` is the parameter block on its own: one row per argument and, when a row loses detail, a toggle that swaps the rows for the full text. Props `args`, `open`, `mask`, `labels`.

The `ui-core` default shows parameter values as they are. It does not mask anything, so a gated call that carries a token or key shows it. Pass `mask` to hide secrets; it applies to both the rows and the full text.

### `QuestionCard`

```svelte
<script lang="ts">
  import { QuestionCard } from "@reactive-agents/svelte/components";
  import type { QuestionBusy, QuestionRequest } from "@reactive-agents/ui-core";

  let { question }: { question: QuestionRequest & { questions?: unknown } } = $props();
  let busy = $state<QuestionBusy | undefined>();
  let error = $state<string | undefined>();

  async function reply(value: unknown) {
    busy = "reply";
    try {
      await sendAnswer(question, value); // your own request
    } catch (e) {
      error = e instanceof Error ? e.message : String(e);
      busy = undefined;
    }
  }
</script>

<QuestionCard
  {question}
  {busy}
  {error}
  onReply={reply}
  onInvalid={(message) => (error = message)}
  onDismiss={() => { busy = "dismiss"; void sendDismiss(question); }}
/>
```

`sendAnswer` and `sendDismiss` are your own requests.

- Props: `question` (`QuestionRequest`: `runId`, `interactionId`, `kind`, `prompt`, `schema`, plus `questions` for a structured ask), `onReply(value)`, `onInvalid(message)` (a required form field left blank), `onHide`, `onDismiss`, `busy` (`"reply" | "dismiss"`), `error`, `labels`, `class`.
- The reply control follows `replyControl`: yes/no for `confirmation`, buttons for `choice`, fields for `form`, otherwise a free-text box. A structured ask replaces the kind's control with `QuestionForm`, and `onReply` then receives the id-keyed answer map. The card is keyed on `interactionId`, so a follow-up question starts with a clean box.
- Snippets: `header({ question, heading })`, `prompt({ question })`, `reply({ question, send })` (the whole reply control), `structured({ questions, send })` (only the structured form), `actions({ dismiss })` (the Dismiss row).
- Hooks: `data-ra-question`, `data-mode` (`busy` or `reply`), `data-action` on Dismiss, `data-run-id`, `data-interaction-id`.
- `QuestionReply` (props `kind`, `schema`, `questions`, `onSend`, `onInvalid`, `labels`, `structured`; hooks `data-ra-question-reply`, `data-control`) and `QuestionForm` (props `questions`, `onSend`, `disabled`, `labels`) work alone in a different frame.

### `ConfigSection`, `FieldRow` and `ListField`

```svelte
<script lang="ts">
  import { ConfigSection, FieldRow, ListField } from "@reactive-agents/svelte/components";
  import { addUnique, removeAt, splitEntries, duplicateIssues } from "@reactive-agents/ui-core";

  let open = $state(true);
  let blocked = $state<string[]>([]);
  const issues = $derived(duplicateIssues(blocked, (k) => `${k} is listed twice.`));
</script>

<ConfigSection id="guardrails" title="Guardrails" open={open} onToggle={() => (open = !open)}>
  {#snippet head()}{blocked.length} blocked{/snippet}
  <FieldRow label="Blocked phrases" for="blocked" description="Runs that match are stopped.">
    {#snippet control()}
      <ListField
        id="blocked"
        items={blocked}
        {issues}
        onAdd={(text) => {
          const entries = splitEntries(text);
          if (entries.length === 0) return false;
          blocked = addUnique(blocked, entries);
        }}
        onRemove={(i) => (blocked = removeAt(blocked, i))}
      />
    {/snippet}
  </FieldRow>
</ConfigSection>
```

- `ConfigSection`: props `id`, `open`, `onToggle`, `title`, `icon` (an icon id), `flat`, `hideTitle`, `idPrefix` (default `ra-config`), `icons`, `class`; snippets `head` (a short summary beside the title) and the body. It is collapsible by default. `flat` makes a plain, always-open panel for layouts where a nav picks what shows; `hideTitle` keeps that heading for screen readers only. Your app owns the open state. Element ids are `{idPrefix}-section-{id}`, `{idPrefix}-head-{id}` and `{idPrefix}-panel-{id}`, for deep links. Hooks: `data-ra-config-section`, `data-open`, `data-flat`.
- `FieldRow`: label and help on the left, the control on the right (stacked under 720px). Props `label`, `for` (the control's id; the help text gets the id `${for}-hint` for `aria-describedby`), `description`, `wide`, `class`; snippets `help` (rich help text in place of `description`) and `control`. Hook: `data-ra-field-row`.
- `ListField`: props `id`, `items`, `text` (an entry's label; default `String`), `onAdd(text)` (return `false` to reject the entry and keep the text in the box), `onRemove(index)`, `issues`, `draft` (bindable), `variant` (`"chips"` default, or `"rows"`), `suggestions`, `labels`, `icons`, `class`. Snippets: `item({ item, index, text, remove, issues })` replaces an entry (it then draws its own remove button), `draftExtras` adds controls between the box and Add, `below` goes under the add row, `empty` shows when there are no entries. Hooks: `data-ra-list-field`, `data-variant`, `data-ra-list-item`.

### `ReceiptCard`

`ReceiptCard` draws the [trust receipt](https://docs.reactiveagents.dev/features/process-model.md#the-trust-receipt) of a finished run: the verdict, the verifier's verdict or that it did not run, how the run ended, the tools used, declared deliverables, each harness intervention, recovered tool effects, provenance, the signature state, and a copy action for the raw JSON. The verdict grades the run's evidence trail, never whether the answer is true. The same card ships for Svelte, [React](https://docs.reactiveagents.dev/features/agentic-ui-react-blocks.md#receipt-card) and [Vue](https://docs.reactiveagents.dev/features/agentic-ui-vue-blocks.md#receipt-card), over one `ui-core` view model (`receiptViewOf`), so the three show the same lines and labels.

```svelte
<script lang="ts">
  import { ReceiptCard } from "@reactive-agents/svelte/components";
  import "@reactive-agents/svelte/styles.css";

  let { receipt, verified }: { receipt: unknown; verified?: boolean } = $props();
</script>

<ReceiptCard {receipt} signature={verified === undefined ? undefined : verified ? "valid" : "invalid"} />
```

The card makes no request and checks no signature. Pass the receipt you have (`AgentResult.receipt`, the `StreamCompleted` event's `receipt`, or a stored copy) and, when you checked it with [`verifyReceipt`](https://docs.reactiveagents.dev/features/process-model.md#the-trust-receipt), the result as `signature`. A signed receipt with no `signature` prop is shown as signed but not checked.

| Prop | Type | What it does |
|---|---|---|
| `receipt` | `unknown` | The receipt. `null` or `undefined` shows the empty state |
| `signature` | `"valid" \| "invalid" \| "unsigned" \| "unchecked"` | The result of your signature check |
| `redacted` | `boolean` (default `false`) | Says the copy at hand had a secret value removed by its keeper. A signed copy then cannot match its signature, and the card says so instead of calling it invalid |
| `noneReason` | `string` | Why there is no receipt, in your words, shown in the empty state |
| `labels` | `Partial<ReceiptCardLabels>` | Reword or translate headings and button text. Defaults: `DEFAULT_RECEIPT_LABELS` |
| `onCopy` | `(json: string) => void` | Replaces the clipboard write of the copy action. In Vue this is the `copy` event |
| `class` | `string` | Extra class on the card (`className` in React) |

Styling and test hooks: `data-ra-receipt`, `data-state`, `data-verdict`, `data-signature`, `data-tone` on graded lines, `data-action="copy"` and `data-testid="receipt-card"`.

### Labels and tokens

Pass any subset of `ApprovalCardLabels`, `QuestionCardLabels`, `ReceiptCardLabels` or `ListFieldLabels` as `labels` to reword or translate. Defaults: `DEFAULT_APPROVAL_LABELS`, `DEFAULT_QUESTION_LABELS`, `DEFAULT_RECEIPT_LABELS`, `DEFAULT_LIST_FIELD_LABELS`.

New tokens: `--ra-card-rail` (the 2px rail down the left of a card; default `--ra-warn`), `--ra-card-tool` (the tool name in an approval card; default `--ra-fg-muted`), `--ra-field-control-width` (default 280px) and `--ra-field-control-width-wide` (default 340px), the control column of a `FieldRow`. They carry `var()` fallbacks and take their colours from tokens that already have light and dark values, so they have no dark set of their own.

## What's Next

- [Drop-in UI blocks overview](https://docs.reactiveagents.dev/features/agentic-ui-blocks.md): the other block pages
- [Agentic UI Core](https://docs.reactiveagents.dev/features/agentic-ui-core.md): the protocol, run state and the other Svelte blocks
- [Web Integration](https://docs.reactiveagents.dev/guides/web-integration.md): React, Vue and Svelte bindings
