Sheet widget (Pro)
ProIncluded in $99A small table the assistant hands over to be corrected: edit a cell, watch totals follow, and send exactly what changed back.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { SheetWidget } from "@/components/ui/chatcn/pro/sheet-widget"
<SheetWidget
title="Lisbon trip costs"
columns={[
{ id: "item", header: "Cost" },
{ id: "amount", header: "Amount", type: "currency", total: "sum" },
{ id: "share", header: "Each of 4", type: "currency", total: "sum",
compute: (row) => Number(row.amount) / 4 },
]}
defaultRows={rows}
currency="EUR"
onSubmit={(changes) => sendToAssistant(changes)}
/>This is not a spreadsheet to live in; for that there is the AI spreadsheet. It is the table an answer comes with, small enough to read at a glance and quick to fix. Move with the arrow keys and type to replace a cell, or press Enter to change it; Enter saves and moves down, Tab moves across, Escape cancels. Worked out columns (compute, marked ƒ) and totals follow at once, and a changed total turns over softly. A cell that doesn't read as a number stays open with the reason under the table. Every edited cell keeps a blue corner, and with onSubmit a bar counts the edits with Undo all and Send, which passes the list of { rowId, columnId, from, to }. formulas lets number cells take arithmetic such as =120*3+40, parsed without eval; it is off by default so an equals sign is never a surprise. baseRows restores a draft against what the assistant sent.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
columns | SheetWidgetColumn[] | { id, header, type?, compute?, total?, width? } |
defaultRows | SheetRow[] | { id, ...cells } |
baseRows | SheetRow[] | What edits count against. Default defaultRows |
currency, locale | string | For currency cells. Default USD |
formulas | boolean | Arithmetic in number cells. Off by default |
addable | boolean | Shows Add row |
onRowsChange | (rows) => void | Every saved edit |
onSubmit | (changes, rows) => void | Shows the change bar |
labels | Partial<SheetWidgetLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Arrow keys, Home, End | Move between cells; Ctrl with Home or End goes to the corners |
| Enter, F2, or typing | Edit the cell |
| Enter, Tab | Save and move down or across; Shift goes back |
| Escape | Cancel the edit |
| Delete | Clear the cell |
Accessibility
- A real table with the grid pattern: one tab stop, arrow keys inside.
- Edited and worked out cells say so to screen readers; an error is an alert tied to the input.
- The change count is a polite live region.
Motion
A changed total fades and unblurs in 260 ms. The error and the Sent note rise in. Reduced motion shows them in place.