Svelte Data Table

Most tables need three things: sorting, filtering and paging. In SvGrid those are opt-in features rather than always-on weight, so a plain read-only table stays small and a full-featured one is a one-line change to the features array.

The component takes a data array and a columns array and renders. Columns are plain objects with a field and a header; everything beyond that, from widths to custom cell snippets, is optional.

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,
    rowSortingFeature, columnFilteringFeature, rowPaginationFeature,
    type ColumnDef,
  } from '@svgrid/grid'

  const features = tableFeatures({ rowSortingFeature, columnFilteringFeature, rowPaginationFeature })

  const columns: ColumnDef<typeof features, Person>[] = [
    { field: 'firstName', header: 'First name' },
    { field: 'age', header: 'Age' },
  ]
</script>

<SvGrid {data} {columns} {features} filterMode="row" showPagination pageSize={50} />

What you get

Live examples

Documentation

Related articles

Frequently asked questions

How do I build a sortable, filterable table in Svelte?

Pass data and columns to <SvGrid> and register rowSortingFeature and columnFilteringFeature through tableFeatures. Sorting and filtering are then handled for you.

What is the difference between a data grid and a data table?

A data table displays rows; a data grid also edits them, virtualizes them, groups them and talks to a server. SvGrid is a grid that is perfectly happy being used as a plain table.

How many rows can it render?

Row and column virtualization keep only the visible window in the DOM, so 100,000 rows by 100 columns stay smooth and a one-million-row demo scrolls fine.

Does it work with SvelteKit and SSR?

Yes. The grid is SSR-ready and the starter templates include a SvelteKit project, so data loaded in a load function renders without a flash of empty table.

Build something else

Get started · Browse the gallery · Pricing