Open this example in the interactive library
Live preview
Source code
// components/ColumnTotalFooter.tsx
export default function ColumnTotalFooter({
rows = [
{ name: "Design", value: 12 },
{ name: "Build", value: 18 },
],
}: { rows?: { name: string; value: number }[] } = {}) {
return (
<table>
<caption>Team hours</caption>
<tbody>
{rows.map((r) => (
<tr key={r.name}>
<th>{r.name}</th>
<td>{r.value}</td>
</tr>
))}
</tbody>
<tfoot>
<tr>
<th>Total</th>
<td>{rows.reduce((sum, r) => sum + r.value, 0)}</td>
</tr>
</tfoot>
</table>
);
}
