A configurable, server-aware data table for Svelte 5 with first-class support for DaisyUI.
FetchApiDataSource, ApiFunctionDataSource, SvelteQueryDataSource, or LocalDataSource (client-side filter, sort, paginate).bind:selectedIds.buildExportUrl to delegate large exports to the server.MessageFormatter.onError callback plus a customisable errorState slot.# Install Tailwind CSS and DaisyUI first (see https://daisyui.com/docs/install)
pnpm add svelte-advanced-datatable
<script lang="ts">
import type { DataTableConfig } from 'svelte-advanced-datatable';
import { ComponentType, FetchApiDataSource } from 'svelte-advanced-datatable';
import { DataTable } from 'svelte-advanced-datatable/daisyUi';
interface UserData {
id: number;
userName: string;
}
const config: DataTableConfig<UserData> = {
type: 'userData',
columnProperties: {
id: { type: ComponentType.NUMBER },
userName: { type: ComponentType.STRING }
},
dataUniquePropertyKey: 'id',
messageConfig: {
id: { label: 'Id' },
userName: { label: 'Username' }
}
};
const dataSource = new FetchApiDataSource<UserData>('/api/users/list');
</script>
<DataTable {config} {dataSource} />
Register actions to automatically get a checkbox column, a per-row dropdown and a bulk toolbar:
<script lang="ts">
import type { SelectionId } from 'svelte-advanced-datatable';
let selectedIds: SelectionId[] = $state([]);
const config: DataTableConfig<UserData> = {
// ...other options
actions: [
{ key: 'edit', onSingle: (user) => editUser(user) },
{ key: 'archive', primary: true, onMulti: (ids) => archive(ids) },
{ key: 'delete', variant: 'destructive', primary: true, onMulti: (ids) => remove(ids) }
]
};
</script>
<DataTable {config} {dataSource} bind:selectedIds />
See the /example/daisy-ui/svelte-query-actions page for a working demo.