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