Components/RecommendationCard

RecommendationCard

An agent suggestion card with its confidence.

VerifiedSince 0.3.9

Usage

Suggestion and Alternatives

Picking an alternative in the drawer promotes it to the current recommendation, closes the drawer, and clears the confirmed state.

Loading demo...

Best Practices

  • Write short to read on its own; it is all the drawer shows.
  • Use ctaTone: 'danger' for risky actions so the primary button's weight matches the consequence.
  • Lift accepted into the host and set it true only after the request succeeds, or readers will think the order was placed.
  • Keep alternatives to two or three; beyond that, use a list page.
  • Use TxToolConfirmation for a binary allow / deny; this card is for multi-option suggestions with confidence.

API Reference

Props

PropTypeDefaultDescription
titlestring—Card heading, usually the question awaiting confirmation. Required.
optionsRecommendationOption[]—The options, required: { key, text?, short, confidence?, signal?, tone?, label, cta?, ctaTone? }.
modelValuestringfirst option's keyKey of the current recommendation, for v-model.
openboolean—The alternatives drawer, for v-model:open; omit to let the card own it.
acceptedboolean—Whether it is confirmed, for v-model:accepted; swaps text and color only, with no undo.
alternativesLabelstring'Alternatives'Text of the drawer toggle.
otherOptionsLabelstring'Other options'Heading inside the drawer.
acceptedLabelstring'Accepted'Primary action text once confirmed.
acceptLabelstring'Accept'Primary action text for an option without cta.

Events

EventArgumentsDescription
update:modelValue(key: string)Fires when the current recommendation changes.
update:open(open: boolean)Fires when the drawer opens or closes.
update:accepted(accepted: boolean)Fires when the confirmed state changes.
accept(option: RecommendationOption)Fires when the primary action is pressed, with the whole option.
select(option: RecommendationOption)Fires when an alternative is picked in the drawer.

Slots

SlotScopeDescription
body{ option }Replaces the rationale; <code> for identifiers, <mark> for entities.
meter{ option }Replaces a meter, in the footer and every drawer row.
footer-extra—Inserted on the left of the footer, before the actions.

Confidence Mapping

confidenceSegmentsDefault color
high3--tx-bui-green
medium2--tx-bui-orange
low1--tx-bui-red
none (default)0--tx-bui-ink-3

signal and tone override the count and the color; tone is a raw CSS color that ignores the theme, so prefer confidence.

Overview

  • The drawer lists only the other options; the current recommendation never appears twice.
  • The collapsed drawer is inert, taking its buttons out of the focus order and the accessibility tree.
  • The rationale has a minimum height (48px by default) so the card doesn't jump between options; tune it with --tx-bui-recommendation-card-body-min-height.
  • In body, <code> renders as an accent-tinted identifier (is-success / is-warning for semantic colors) and <mark> as an entity pill whose dot reads --tx-entity-color, neutral grey by default.

Technologies

  • The footer and drawer meters are TxSignalMeter, usable on its own.
  • Adapted from Beautiful UI (© 2026 Shane Levine, MIT).
  • Source: packages/tuffex/packages/components/src/recommendation-card/.
查看源码
packages/tuffex/packages/components/src/recommendation-card/index.ts