Header Checkbox

A select-all checkbox with support for an indeterminate state.

Pass indeterminate when some rows are selected and checked when all rows are selected.

0 of 4 rows selected

ProjectStatus
Website redesignIn progress
Mobile applicationPlanning
Analytics dashboardIn progress
Customer portalComplete

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/header-checkbox.json

Column definition

The example selects all filtered rows. For page-only selection, use getIsAllPageRowsSelected and toggleAllPageRowsSelected instead.

columns.ts

Render the header

TanStack Table v9 renders the component configuration with FlexRender.

data-table.svelte

Props

Header checkbox props

NameTypeDefaultDescription
checkedbooleanrequiredWhether all target rows are selected.
indeterminatebooleanfalseShows that some, but not all, target rows are selected.
onCheckedChange(checked: boolean) => voidrequiredCalled when the user toggles select all.
aria-labelstring"Select all rows"Accessible label for the checkbox.
classstringundefinedClasses forwarded to the underlying checkbox.
...restPropsCheckbox propsundefinedForwards supported checkbox props such as disabled, name, and value.