Score breakdown

ScoreBreakdown renders a total score with a verdict pill, then lists each weighted criterion with its score, a thin meter bar, and an optional note. It makes the arithmetic behind a verdict visible.

Score breakdown
LIVE · running in a sandboxed iframe
Installed with shadcn add · 1 workaround · theme from registry.json
  • installed base item https://r.assistant-ui.com/shimmer-style.json (registry preview settings)
See how it was built

Installation

pnpm dlx shadcn@latest add @assistant-ui/elements-score-breakdown

Requires @assistant-ui in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { ScoreBreakdown, type ScoreCriterion } from "@/components/assistant-ui/elements/score-breakdown";export function Scorecard({ criteria }: { criteria: readonly ScoreCriterion[] }) {  return (    <ScoreBreakdown      verdict="Strong"      total={82.5}      outOf={100}      criteria={criteria}      visibleCount={criteria.length}    />  );}
  • Showing a verdict or grade together with the per-criterion scores and weights that produced it, such as an evaluation, review, or rubric result.
  • Explaining why an overall score is low by surfacing the weakest criteria with their notes.
  • Presenting an AI-generated assessment where users need to audit how the total was calculated.
  • Displaying a compact scorecard in a chat or sidebar panel where the criteria list should progressively reveal via visibleCount.

Examples

Full breakdown with notes

Shows every criterion with weights and a note explaining a deduction.

full-breakdown-with-notes.tsx
import { ScoreBreakdown } from "@/components/assistant-ui/elements/score-breakdown";export function ReviewScore() {  return (    <ScoreBreakdown      verdict="Strong"      total={82.5}      outOf={100}      visibleCount={3}      criteria={[        { label: "Accuracy", score: 90, weight: 2 },        { label: "Clarity", score: 80, weight: 1, note: "Two sections use undefined jargon." },        { label: "Coverage", score: 75, weight: 1 },      ]}    />  );}

Low verdict with progressive reveal

Uses a red verdict (total below 50% of outOf) and reveals criteria one at a time via visibleCount.

low-verdict-with-progressive-reveal.tsx
import { useState } from "react";import { ScoreBreakdown } from "@/components/assistant-ui/elements/score-breakdown";const criteria = [  { label: "Sources cited", score: 20, weight: 3, note: "No references provided." },  { label: "Reasoning", score: 45, weight: 2 },  { label: "Formatting", score: 70, weight: 1 },];export function RevealScore() {  const [visibleCount, setVisibleCount] = useState(1);  return (    <div className="flex flex-col gap-2">      <ScoreBreakdown        verdict="Weak"        total={31}        outOf={100}        criteria={criteria}        visibleCount={visibleCount}      />      <button type="button" onClick={() => setVisibleCount((n) => Math.min(n + 1, criteria.length))}>        Show next      </button>    </div>  );}

Custom class on the container

Passes className and standard div attributes through to the root element.

custom-class-on-the-container.tsx
import { ScoreBreakdown } from "@/components/assistant-ui/elements/score-breakdown";export function SidebarScore() {  return (    <ScoreBreakdown      className="max-w-xs"      aria-labelledby="score-heading"      verdict="Good"      total={66}      outOf={100}      visibleCount={2}      criteria={[        { label: "Speed", score: 70, weight: 1 },        { label: "Cost", score: 62, weight: 1 },      ]}    />  );}

API reference

PropTypeDefaultDescription
verdictstring—Label shown in the pill at the top right. Its color is chosen from total/outOf: emerald at 0.75 or higher, amber at 0.5 or higher, red otherwise.
totalnumber—Achieved total score, displayed with one decimal place. Used with outOf to compute the ratio that picks the verdict color.
outOfnumber—Maximum possible score. Displayed after the total, and used as the denominator for each criterion's bar. If 0, the ratio is treated as 0.
criteriareadonly ScoreCriterion[]—Criteria to list. Each ScoreCriterion has label (string, used as the React key and accessible name), score (number), weight (number, shown as ×weight), and optional note (string).
visibleCountnumber—How many criteria from the start of the criteria array to render. Passed to the range helper take(), so it limits the list without changing the total.
classNamestring—Additional classes merged onto the root div via cn(). Optional.

Accessibility

  • Each criterion's bar is a span with role="meter" and aria-label set to "<label> score".
  • aria-valuemin is 0 and aria-valuemax is 100. aria-valuenow is the criterion's percentage of outOf, passed through the announced() helper.
  • aria-valuetext gives a human-readable value such as "80.0 of 100", so screen readers do not rely on the percentage alone.
  • Bar fill colors are set with forced-color-adjust-none, and the track uses forced-colors:outline so the meter stays visible in forced-colors mode.
  • Bar animation is removed with motion-reduce:transition-none for users who prefer reduced motion.
  • The verdict is conveyed as text, not color alone. Color is supplementary.
  • Criteria labels are truncated with CSS and remain in the DOM. Long notes wrap via break-words.
  • Root div props are forwarded, so add aria-labelledby or aria-label to name the scorecard region. The component does not set a role on the root.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Score breakdown" component (assistant-ui/elements-score-breakdown) from its shadcn registry.1. Install it with: npx shadcn@latest add @assistant-ui/elements-score-breakdown2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: verdict, total, outOf, criteria, visibleCount, className.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { ScoreBreakdown, type ScoreCriterion } from "@/components/assistant-ui/elements/score-breakdown";export function Scorecard({ criteria }: { criteria: readonly ScoreCriterion[] }) {  return (    <ScoreBreakdown      verdict="Strong"      total={82.5}      outOf={100}      criteria={criteria}      visibleCount={criteria.length}    />  );}```

Files & dependencies

  • components/assistant-ui/elements/score-breakdown.tsx
registryDependencieshttps://r.assistant-ui.com/elements-surfaces.jsonhttps://r.assistant-ui.com/elements-range.json

Looks similar, elsewhere