Skip to content
Tools— browse docs
On this page

Step 3: Edit and add rows

A read-only list isn't a sheet. Wire each cell to actions.list("rows"), and give it an Add button.

A sheet you can't edit isn't a sheet. actions.list("rows") gives you three positional operations, and they're all this build needs — insert and move exist too, for when you get to reordering (SDK reference):

const addRow = () => actions.list("rows").push({ item: "", quantity: 1, price: 0 })

<input
  value={row.item}
  onChange={(e) => actions.list("rows").replace(i, { ...row, item: e.target.value })}
/>

<button onClick={() => actions.list("rows").remove(i)}>×</button>

Turn the plain list into a table: one <input> per column, an Add a row button above it, and a × to remove one.

Edit, add, remove
src/codec.ts + src/tool.tsx Line 45 highlighted.

Edit and the example re-runs. Tab indents; press Escape to leave the editor.

Running · your edits, live
Starting the example…

You should see: edit the price on "Torch", tab away — it sticks. Click Add a row, a blank one appears at the bottom. Click × on any row and it's gone.

Next steps