Data Table
glasswave/data-tableFreeComponent
TanStack Table headless bindings with glass table chrome.
Live preview
live · rendered by the registry
Rendered by glasswave on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://glasswave.denizisik.com/r/data-table.jsonSource
1"use client";23import {4 type Column,5 type ColumnDef,6 flexRender,7 getCoreRowModel,8 getSortedRowModel,9 type SortingState,10 useReactTable,11} from "@tanstack/react-table";12import { ArrowDown, ArrowUp, ChevronsUpDown } from "lucide-react";13import { useState } from "react";14import { cn } from "@/lib/utils";15import { Button } from "@/components/ui/button";16import {17 Table,18 TableBody,19 TableCell,20 TableHead,21 TableHeader,22 TableRow,23} from "@/components/ui/table";2425export interface DataTableProps<TData, TValue> {26 columns: ColumnDef<TData, TValue>[];27 data: TData[];28 className?: string;29 /** Enable client-side sorting for sortable columns */30 enableSorting?: boolean;31}3233export function DataTable<TData, TValue>({34 columns,35 data,36 className,37 enableSorting = true,38}: DataTableProps<TData, TValue>) {39 const [sorting, setSorting] = useState<SortingState>([]);4041 const table = useReactTable({42 data,43 columns,44 state: enableSorting ? { sorting } : undefined,45 onSortingChange: enableSorting ? setSorting : undefined,46 getCoreRowModel: getCoreRowModel(),47 getSortedRowModel: enableSorting ? getSortedRowModel() : undefined,48 });4950 return (51 <div className={cn("w-full space-y-4", className)}>52 <Table>53 <TableHeader>54 {table.getHeaderGroups().map((headerGroup) => (55 <TableRow key={headerGroup.id}>56 {headerGroup.headers.map((header) => (57 <TableHead key={header.id} className="whitespace-nowrap">58 {header.isPlaceholder59 ? null60 : flexRender(61 header.column.columnDef.header,62 header.getContext(),63 )}64 </TableHead>65 ))}66 </TableRow>67 ))}68 </TableHeader>69 <TableBody>70 {table.getRowModel().rows.length ? (71 table.getRowModel().rows.map((row) => (72 <TableRow73 key={row.id}74 data-state={row.getIsSelected() && "selected"}75 >76 {row.getVisibleCells().map((cell) => (77 <TableCell key={cell.id}>78 {flexRender(cell.column.columnDef.cell, cell.getContext())}79 </TableCell>80 ))}81 </TableRow>82 ))83 ) : (84 <TableRow>85 <TableCell86 colSpan={columns.length}87// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from glasswave
All 60 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | glasswave | Components | Free | 2 deps | |
| Alertalert | glasswave | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | glasswave | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | glasswave | Components | Free | 1 dep | |
| Avataravatar | glasswave | Components | Free | 1 dep | |
| Badgebadge | glasswave | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | glasswave | Components | Free | 2 deps | |
| Buttonbutton | glasswave | Components | Free | 2 deps |
