Tree Table — Selection
shadcn-table-library/tree-table-selectionFreeBlock
Tree table with cascading checkbox selection and indeterminate state for partially-selected branches.
Install it
npx shadcn@latest add https://shad-table.dev/r/tree-table-selection.jsonSource
1'use client'23import type { ColumnDef } from '@tanstack/react-table'4import { ChevronRight } from 'lucide-react'56import { Checkbox } from '#/components/ui/checkbox.tsx'78export type OrgNode = {9 id: string10 name: string11 role: string12 status: string13 children?: OrgNode[]14}1516export const columns: ColumnDef<OrgNode>[] = [17 {18 id: 'select',19 header: ({ table }) => (20 <Checkbox21 checked={22 table.getIsAllRowsSelected()23 ? true24 : table.getIsSomeRowsSelected()25 ? 'indeterminate'26 : false27 }28 onCheckedChange={(value) => table.toggleAllRowsSelected(!!value)}29 aria-label="Select all rows"30 />31 ),32 cell: ({ row }) => (33 <Checkbox34 checked={35 row.getIsSelected()36 ? true37 : row.getIsSomeSelected()38 ? 'indeterminate'39 : false40 }41 onCheckedChange={(value) => row.toggleSelected(!!value)}42 aria-label="Select row"43 />44 ),45 enableSorting: false,46 },47 {48 accessorKey: 'name',49 header: 'Name',50 cell: ({ row }) => (51 <div52 className="flex items-center gap-1.5"53 style={{ paddingLeft: `${row.depth * 1.25}rem` }}54 >55 {row.getCanExpand() ? (56 <button57 type="button"58 onClick={row.getToggleExpandedHandler()}59 className="flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground"60 aria-label={row.getIsExpanded() ? 'Collapse row' : 'Expand row'}61 >62 <ChevronRight63 className={`h-3.5 w-3.5 transition-transform ${64 row.getIsExpanded() ? 'rotate-90' : ''65 }`}66 />67 </button>68 ) : (69 <span className="w-4 shrink-0" />70 )}71 {row.original.name}72 </div>73 ),74 },75 {76 accessorKey: 'role',77 header: 'Role',78 sortingFn: 'alphanumeric',79 },80 {81 accessorKey: 'status',82 header: 'Status',83 sortingFn: 'basic',84 },85]
What it pulls in
npm packages
Other registry items
Files it writes
More from shadcn-table-library
All 18 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Icons Tableanimated-icons-table | shadcn-table-library | Blocks | Free | 2 deps · 9 files | |
| Comparison Tablecomparison-table | shadcn-table-library | Blocks | Free | 1 dep · 4 files | |
| Data Tabledata-table | shadcn-table-library | Blocks | Free | 1 dep · 4 files | |
| Density & Exportdensity-export-table | shadcn-table-library | Blocks | Free | 1 dep · 4 files | |
| Editable Tableeditable-table | shadcn-table-library | Blocks | Free | 1 dep · 3 files | |
| Grouped Tablegrouped-table | shadcn-table-library | Blocks | Free | 1 dep · 3 files | |
| Heatmap Tableheatmap-table | shadcn-table-library | Blocks | Free | 1 dep · 4 files | |
| Summary / KPI Tablekpi-table | shadcn-table-library | Blocks | Free | 1 dep · 5 files |
