{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"confidence-answer","type":"registry:ui","title":"Confidence Answer","description":"An answer that says how sure it is — a warning badge only when there is something to warn about, and a hedge that names what to verify.","author":"Scrim UI (https://scrimui.dev)","categories":["safety"],"docs":"https://scrimui.dev/components/confidence-answer","dependencies":[],"registryDependencies":[],"files":[{"path":"src/showcase/confidence-answer/confidence-answer.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * An answer that says how sure it is.\n *\n * Language models are wrong in the same tone of voice they are right, and a\n * reader has no way to tell which they just got. The fix is not a disclaimer\n * under the whole chat (\"AI can make mistakes\" — invisible by day two); it is\n * a qualifier attached to *this* answer, calibrated to *this* claim.\n *\n * **Badge the uncertainty, not the certainty.** A \"high confidence\" mark on\n * every solid answer trains the eye to skip the badge row entirely, and the\n * one answer that needed scrutiny gets it least. High confidence renders as\n * quiet text; the badge appears when there is something to warn about.\n *\n * **The hedge belongs at the claim, not the footer.** `hedge` sits directly\n * under the answer, one sentence saying *what specifically* might be off —\n * a number, a date, a version. \"This might be wrong\" is noise; \"I may be\n * confusing this with the 2023 edition\" is information.\n *\n * **Never a bare percentage.** \"73% confident\" borrows the vocabulary of\n * measurement for a number that is not one. Three honest levels — phrased as\n * guidance on what to do next — beat a false-precision score every time.\n */\n\nexport type ConfidenceAnswerProps = {\n  /** How sure the answer is. Drives both the badge and its wording. */\n  confidence: \"high\" | \"medium\" | \"low\";\n  /** The answer itself. */\n  text: string;\n  /** The specific thing to double-check, in one sentence — shown for medium and low. */\n  hedge?: string;\n  className?: string;\n};\n\nconst LEVELS = {\n  medium: { label: \"Worth double-checking\", dot: \"bg-amber-500\", text: \"text-amber-700 dark:text-amber-400\" },\n  low: { label: \"Treat as a guess\", dot: \"bg-red-500\", text: \"text-red-700 dark:text-red-400\" },\n} as const;\n\n/* ------------------------------------------------------------------ */\n/* ConfidenceAnswer                                                    */\n/* ------------------------------------------------------------------ */\n\nexport function ConfidenceAnswer({\n  confidence,\n  text,\n  hedge,\n  className = \"\",\n}: ConfidenceAnswerProps) {\n  const warn = confidence !== \"high\";\n  const level = warn ? LEVELS[confidence] : null;\n\n  const surface =\n    confidence === \"low\"\n      ? \"border-red-200 bg-red-50/50 dark:border-red-900/40 dark:bg-red-950/20\"\n      : confidence === \"medium\"\n        ? \"border-amber-200 bg-amber-50/50 dark:border-amber-900/40 dark:bg-amber-950/20\"\n        : \"border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900\";\n\n  return (\n    <div className={`rounded-2xl rounded-tl-md border px-4 py-3 ${surface} ${className}`}>\n      <p className=\"text-sm leading-6 text-zinc-900 dark:text-zinc-100\">{text}</p>\n\n      {/* High confidence renders as a plain answer — badging certainty trains\n          the eye to skip the badge row, and the warning that matters gets\n          ignored with the rest. */}\n      {level && (\n        <div className=\"mt-2 flex items-center gap-1.5\">\n          <span className={`h-1.5 w-1.5 shrink-0 rounded-full ${level.dot}`} />\n          <span className={`text-xs font-medium ${level.text}`}>{level.label}</span>\n        </div>\n      )}\n\n      {/* zinc-600 on the amber surface: zinc-500 measures under AA at 13px. */}\n      {warn && hedge && (\n        <p className=\"mt-1 text-[13px] leading-5 text-zinc-600 dark:text-zinc-400\">{hedge}</p>\n      )}\n    </div>\n  );\n}\n","type":"registry:ui","target":"components/ui/confidence-answer.tsx"}]}