Confidence Badge
A small pill under an AI answer that says how much to trust it. A signal meter and label show high, medium or low confidence, and hovering shows the checks behind it.
Preview
When did Apollo 11 land on the Moon?
Apollo 11 landed on the Moon on July 20, 1969. Neil Armstrong and Buzz Aldrin walked on the surface.
Checking facts…Setup
Install with the shadcn CLI
One command adds every file, the npm packages and any Kinetik components it builds on. Needs a components.json; the CLI offers to create one if your project has none.
Or install manually
- 1
Run in your terminal:
$npm install clsx tailwind-merge framer-motion lucide-react - 2
Copy
lib/utils.tsfrom the Code tab. Skip if you already havecn(). - 3
Copy
styles/tokens.cssfrom the Code tab and import it in your global CSS after Tailwind:@import "./styles/tokens.css"; - 4
Create a
components/ui/confidence-badge/folder and copy every file from the Code tab into it. Each file does one job, so you can read or change a piece without the rest. - 5
Import and render:
Exampleimport { ConfidenceBadge } from "@/components/ui/confidence-badge" <ConfidenceBadge score={0.86} />
Usage
Pass a score from 0 to 1. The badge picks the level for you:
import { ConfidenceBadge } from "@/components/ui/confidence-badge"
<ConfidenceBadge score={0.86} />| Score | Level | Shows |
|---|---|---|
| 0.75 and up | high | Green, four bars, “High confidence” |
| 0.45 to 0.75 | medium | Amber, two bars, “Medium confidence” |
| Below 0.45 | low | Red, one bar, “May be inaccurate” |
| No score | checking | Pulsing bars, “Checking facts…” |
While your app is still checking the answer, leave out score. The bars pulse until you pass one.
Show the checks
Pass checks to explain the rating. Hovering or focusing the badge opens a card with the score
and each check:
<ConfidenceBadge
score={0.61}
checks={[
{ label: "Backed by 2 sources", status: "pass" },
{ label: "Sources disagree on the number", status: "warn" },
{ label: "Answer may be made up", status: "fail" },
]}
/>Use level to set the level yourself, label to change the text (for example “Verified”), and
showScore={false} to hide the percentage.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
score | number | — | 0 to 1. Leave it out while checking. |
level | "high" | "medium" | "low" | "checking" | from score | Sets the level yourself. |
label | string | per level | Replaces the badge text. |
showScore | boolean | true | Show the percentage. |
checks | ConfidenceCheck[] | — | Each check: { label, status: "pass" | "warn" | "fail" }. |
Accessibility
- Without checks, the badge is a status (
role="status"), so screen readers announce changes like “Checking facts…” to “High confidence, 94%” - With checks, it's a button that opens the card on hover or keyboard focus. Escape closes it
- Each check icon has a label: Passed, Warning or Failed
- Colour is never the only signal: the label and number of bars change too