Skip to content

Toolbars

OptionWhat it does
enableTopToolbar, enableBottomToolbarShow or hide each toolbar.
enableToolbarInternalActionsThe group of built in buttons (search, filters, density, columns, full screen).
enableGlobalFilter, positionGlobalFilterThe search box, and whether it sits 'left', 'right' or 'none'.
enableDensityToggleCompact / comfortable / spacious. Start with initialState: { density: 'compact' }.
enableFullScreenToggleThe full screen button. Control it with state: { isFullScreen }.
enableFilters, enableHiding, enableColumnFiltersHide the matching toolbar buttons.

Add your own buttons next to the built in ones with topToolbarCustomActions or bottomToolbarCustomActions. They receive the table instance.

<script lang="ts">
import Button, { Label } from '@smui/button';
</script>
{#snippet topToolbarCustomActions({ table })}
<Button
disabled={table.getSelectedRowModel().rows.length === 0}
onclick={() => remove(table.getSelectedRowModel().rows)}
>
<Label>Delete selected</Label>
</Button>
{/snippet}
<MaterialSvelteTable options={{ columns, data, enableRowSelection: true, topToolbarCustomActions }} />

toolbarInternalActions replaces the group of built in buttons entirely. To keep them, render them yourself or add your buttons through topToolbarCustomActions instead.

Provide the topToolbar or bottomToolbar snippet to render something completely different. The snippet receives { table }:

{#snippet topToolbar({ table })}
<div>{table.getPrePaginatedRowModel().rows.length} people</div>
{/snippet}

The banner above the table shows selection and grouping info and loading errors. Position it with positionToolbarAlertBanner, show your own message with state: { showAlertBanner: true } and the toolbarAlertBannerProps option, or replace its content with the toolbarAlertBannerContent snippet.