Svelte Editable Table

Editing is opt-in per column, which is the safe default: turn on enableInlineEditing and a column with no editorType stays read-only. Give a column an editorType and it gets the right editor, whether that is a text box, a number field, a checkbox, a date picker or a dropdown backed by your own options.

Commits come back to you as events rather than mutations. onCellValueChange hands you the row, the column, the old value and the new one, so validation, optimistic updates and a save button are all decisions you make.

Install

npm i @svgrid/grid

Free and MIT-licensed in @svgrid/grid: no license key, no row cap, no watermark.

The code

<script lang="ts">
  import { SvGrid, tableFeatures, type ColumnDef } from '@svgrid/grid'

  const features = tableFeatures({})

  const columns: ColumnDef<typeof features, Person>[] = [
    { field: 'firstName', header: 'First',  editorType: 'text' },
    { field: 'age',       header: 'Age',    editorType: 'number' },
    { field: 'joinedAt',  header: 'Joined', editorType: 'date' },
    { field: 'active',    header: 'Active', editorType: 'checkbox' },
  ]
</script>

<SvGrid
  {data}
  {columns}
  {features}
  enableInlineEditing={true}
  onCellValueChange={(e) => save(e.row, e.columnId, e.newValue)}
/>

What you get

Live examples

Documentation

Related articles

Frequently asked questions

How do I make a Svelte table editable?

Set enableInlineEditing on <SvGrid> and give each editable column an editorType. Columns without an editorType stay read-only even when editing is enabled.

How do I save an edit?

Handle onCellValueChange, which reports the row, the column id, the old value and the new one. Persist it however you like; the grid does not write to your data itself.

Can I use a dropdown in a cell?

Yes. Use editorType 'list' with editorOptions, which accepts plain values or objects with a label and a colour for a chip-style editor.

Is inline editing free?

Yes. Editing, the provided editors, validation, the fill handle and undo are all MIT-licensed in @svgrid/grid.

Build something else

Get started · Browse the gallery · Pricing