createSvelteTable (data-table/data-table.svelte.ts)

modernstack-saas · src/lib/components/ui/data-table/data-table.svelte.ts · typescript · MIT
ui, UI / Frontend

Provides a reactive TanStack Table instance for Svelte, enabling developers to manage complex table states using Svelte 5 runes.

// Source: https://github.com/joachimchauvet/modernstack-saas | License: MIT | Copyright 2025 joachimchauvet | https://github.com/joachimchauvet/modernstack-saas
// Provided via justclaw.it.com; keep this notice with the code.
import {
	type RowData,
	type TableOptions,
	type TableOptionsResolved,
	type TableState,
	createTable,
} from "@tanstack/table-core";

/**
 * Creates a reactive TanStack table object for Svelte.
 * @param options Table options to create the table with.
 * @returns A reactive table object.
 * @example
 * ```svelte
 * <script>
 *   const table = createSvelteTable({ ... })
 * </script>
 *
 * <table>
 *   <thead>
 *     {#each table.getHeaderGroups() as headerGroup}
 *       <tr>
 *         {#each headerGroup.headers as header}
 *           <th colspan={header.colSpan}>

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key