SvelteTable is a flexible and powerful headless data table solution for Svelte applications. With its headless architecture, SvelteTable allows you to fully control the markup and styles while offering advanced features like sorting, filtering, pagination, and more.
Install SvelteTable via npm:
npm install @geodask/svelte-table
or using yarn:
yarn add @geodask/svelte-table
or pnpm:
pnpm add @geodask/svelte-table
Here’s how to set up a simple table:
<script lang="ts">
import { createTable } from '@geodask/svelte-table';
const data = [
{ id: 1, name: 'Alice', age: 25 },
{ id: 2, name: 'Bob', age: 30 },
];
const columns = [
{ id: 'id', header: 'ID', accessorKey: 'id' },
{ id: 'name', header: 'Name', accessorKey: 'name' },
{ id: 'age', header: 'Age', accessorKey: 'age' },
];
const table = createTable(data, columns, {
pagination: { pageSize: 5, page: 1 },
});
</script>
<table>
<thead>
<tr>
{#each table.headers as header}
<th>{header.label}</th>
{/each}
</tr>
</thead>
<tbody>
{#each table.rows as row}
<tr>
{#each row.cells as cell}
<td>{cell.value}</td>
{/each}
</tr>
{/each}
</tbody>
</table>
Explore the official documentation to learn more about:
Check out the Examples to see SvelteTable in action and get inspired.
We welcome contributions from the community! To get started:
git checkout -b feature/your-feature-name).git commit -m 'Add new feature').git push origin feature/your-feature-name).Check the contribution guidelines for more information.
This project is licensed under the MIT License. See the LICENSE file for details.