Open this example in the interactive library
Live preview
Source code
// components/HorizontalBarComparison.tsx
export default function HorizontalBarComparison({
rows = [
{ name: "Design", value: 12 },
{ name: "Build", value: 18 },
],
}: { rows?: { name: string; value: number }[] } = {}) {
const max = Math.max(1, ...rows.map((r) => r.value));
return (
<dl>
{rows.map((r) => (
<div key={r.name}>
<dt>{r.name}</dt>
<dd>
<meter aria-label={r.name} value={r.value} max={max} /> {r.value}
</dd>
</div>
))}
</dl>
);
}
