
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
@abaktiar/datagrid
Advanced tools
A powerful, feature-rich React DataGrid component with TypeScript support, built on TanStack Table. Features customizable floating action dock, Excel/CSV export, and advanced row selection.
A powerful, feature-rich React DataGrid component with TypeScript support, built on TanStack Table.
npm install @abaktiar/datagrid
or
yarn add @abaktiar/datagrid
or
pnpm add @abaktiar/datagrid
Make sure you have the required peer dependencies installed:
npm install react react-dom
import React from 'react';
import { DataGrid, DataGridColumn } from '@abaktiar/datagrid';
import '@abaktiar/datagrid/styles';
interface User {
id: number;
name: string;
email: string;
age: number;
}
const data: User[] = [
{ id: 1, name: 'John Doe', email: 'john@example.com', age: 30 },
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', age: 25 },
// ... more data
];
const columns: DataGridColumn<User>[] = [
{
accessorKey: 'id',
header: 'ID',
size: 80,
},
{
accessorKey: 'name',
header: 'Name',
size: 200,
},
{
accessorKey: 'email',
header: 'Email',
size: 250,
},
{
accessorKey: 'age',
header: 'Age',
size: 100,
},
];
function App() {
return (
<DataGrid
data={data}
columns={columns}
enableSorting
enableFiltering
enablePagination
enableRowSelection
pageSize={10}
/>
);
}
export default App;
Import the CSS file in your application:
import '@abaktiar/datagrid/styles';
import {
DataGrid,
createCopyValueAction,
createEmailAction,
createCommonCellActions
} from '@abaktiar/datagrid';
const columns: DataGridColumn<User>[] = [
{
accessorKey: 'email',
header: 'Email',
cellConfig: {
contextMenu: {
items: [
createCopyValueAction(),
createEmailAction(),
...createCommonCellActions(),
],
},
},
},
];
import {
DataGrid,
createExportExcelAction,
createExcelExportBundle
} from '@abaktiar/datagrid';
const tableContextMenu = {
items: [
createExportExcelAction('users.xlsx'),
...createExcelExportBundle(),
],
};
<DataGrid
data={data}
columns={columns}
tableContextMenu={tableContextMenu}
/>
The Floating Action Dock provides customizable floating buttons for bulk operations on selected rows:
import {
DataGrid,
createCommonFloatingActions,
createExportSelectedToExcelAction,
createFloatingActionSeparator
} from '@abaktiar/datagrid';
// Basic floating dock with built-in actions
<DataGrid
data={data}
columns={columns}
enableRowSelection={true}
floatingActionDock={{
enabled: true,
position: 'bottom-center',
showCount: true,
items: createCommonFloatingActions({
enableExportExcel: true,
enableExportCSV: true,
}),
}}
/>
// Advanced customization with custom buttons
const CustomExcelButton = ({ onClick, disabled, children }) => (
<button
onClick={onClick}
disabled={disabled}
style={{
background: 'linear-gradient(135deg, #2E8B57, #228B22)',
color: 'white',
border: 'none',
borderRadius: '8px',
padding: '10px 16px',
fontSize: '13px',
fontWeight: '600',
display: 'flex',
alignItems: 'center',
gap: '8px',
}}
>
{children}
</button>
);
<DataGrid
data={data}
columns={columns}
enableRowSelection={true}
floatingActionDock={{
enabled: true,
position: 'bottom-center',
items: [
// Customized built-in actions
...createCommonFloatingActions({
excelOptions: {
label: 'Premium Excel Export',
icon: '🚀',
customButton: CustomExcelButton,
},
csvOptions: {
label: 'Export CSV',
icon: '📊',
variant: 'primary',
},
}),
// Add separator
createFloatingActionSeparator(),
// Custom business actions
{
label: 'Archive Selected',
icon: '📦',
variant: 'default',
onClick: (selectedData) => {
console.log('Archiving:', selectedData);
},
},
],
}}
/>
Option | Type | Default | Description |
---|---|---|---|
enabled | boolean | false | Enable the floating dock |
position | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right' | 'bottom-center' | Dock position |
showCount | boolean | true | Show selected items count |
items | FloatingActionItem[] | [] | Array of action items |
// Built-in export actions with customization
createExportSelectedToExcelAction({
// File options
filename: 'my-export.xlsx',
columnMapping: { id: 'ID', name: 'Full Name' },
// Visual customization
label: 'Download Excel',
icon: '💾',
variant: 'success',
className: 'my-custom-class',
customButton: MyCustomButton,
})
// Completely custom action
{
label: 'Custom Action',
icon: '⭐',
variant: 'primary',
onClick: (selectedData, selectedIndices) => {
// Your custom logic here
console.log('Selected:', selectedData);
},
customButton: MyCustomButtonComponent, // Optional
}
const columns: DataGridColumn<User>[] = [
{
accessorKey: 'age',
header: 'Age',
cellConfig: {
format: (value) => `${value} years old`,
style: (value) => ({
color: value < 30 ? 'green' : 'blue',
fontWeight: 'bold',
}),
},
},
];
import React, { useState } from 'react';
import { DataGrid, SortingState, PaginationState } from '@abaktiar/datagrid';
function ControlledDataGrid() {
const [sorting, setSorting] = useState<SortingState>([]);
const [pagination, setPagination] = useState<PaginationState>({
pageIndex: 0,
pageSize: 10,
});
return (
<DataGrid
data={data}
columns={columns}
sorting={sorting}
onSortingChange={setSorting}
pagination={pagination}
onPaginationChange={setPagination}
manualPagination
rowCount={totalRows}
/>
);
}
Prop | Type | Default | Description |
---|---|---|---|
data | T[] | required | Array of data objects |
columns | DataGridColumn<T>[] | required | Column definitions |
enableSorting | boolean | true | Enable column sorting |
enableFiltering | boolean | true | Enable column filtering |
enablePagination | boolean | true | Enable pagination |
enableRowSelection | boolean | false | Enable row selection |
enableColumnResizing | boolean | true | Enable column resizing |
enableGlobalSearch | boolean | true | Enable global search |
pageSize | number | 10 | Default page size |
density | 'compact' | 'comfortable' | 'spacious' | 'comfortable' | Table density |
theme | 'light' | 'dark' | 'auto' | 'light' | Theme |
loading | boolean | false | Show loading indicator |
floatingActionDock | FloatingActionDockConfig | undefined | Floating action dock configuration |
interface DataGridColumn<T> {
accessorKey: string;
header: string;
size?: number;
minSize?: number;
maxSize?: number;
enableSorting?: boolean;
enableFiltering?: boolean;
enableResizing?: boolean;
// Cell configuration
cellConfig?: {
format?: (value: any, row: T) => React.ReactNode;
style?: React.CSSProperties | ((value: any, row: T) => React.CSSProperties);
className?: string | ((value: any, row: T) => string);
align?: 'left' | 'center' | 'right';
tooltip?: boolean | ((value: any, row: T) => string);
contextMenu?: {
items: ContextMenuItem<T>[];
};
};
// Header configuration
headerConfig?: {
align?: 'left' | 'center' | 'right';
className?: string;
tooltip?: string;
};
}
createCopyValueAction()
- Copy cell value to clipboardcreateCopyRowAction()
- Copy entire row datacreateEmailAction()
- Open email clientcreatePhoneAction()
- Handle phone number actionscreateOpenUrlAction()
- Open URLs in new tabcreateGoogleSearchAction()
- Search value on GooglecreateExportCsvAction()
- Export table to CSVcreateExportJsonAction()
- Export table to JSONcreateExportExcelAction()
- Export table to ExcelcreatePrintAction()
- Print tablecreateRefreshAction()
- Refresh table datacreateExportSelectedToExcelAction()
- Excel export for selected rowscreateExportSelectedToCSVAction()
- CSV export for selected rowscreateFloatingActionSeparator()
- Visual separator for floating actionscreateCommonFloatingActions()
- Bundle of common floating actionscreateExcelExportBundle()
- Complete Excel export menucreateQuickExcelExport()
- Quick export functionexcelExportPresets
- Predefined export configurationsThe DataGrid supports multiple themes and customization options:
<DataGrid
data={data}
columns={columns}
theme="dark"
density="compact"
className="my-custom-grid"
tableClassName="my-table"
headerClassName="my-header"
bodyClassName="my-body"
/>
You can customize the appearance using CSS custom properties:
:root {
--datagrid-primary-color: #3b82f6;
--datagrid-border-color: #e5e7eb;
--datagrid-header-bg: #f9fafb;
--datagrid-row-hover-bg: #f3f4f6;
}
<DataGrid
data={data}
columns={columns}
searchConfig={{
enabled: true,
placeholder: 'Search users...',
position: 'top',
showIcon: true,
debounceMs: 300,
}}
/>
The DataGrid automatically handles overflow and provides smooth scrolling on mobile devices:
<DataGrid
data={data}
columns={columns}
density="compact" // Better for mobile
searchConfig={{ position: 'top' }}
/>
memo
for custom cell renderersContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by abaktiar
FAQs
A powerful, feature-rich React DataGrid component with TypeScript support, built on TanStack Table. Features customizable floating action dock, Excel/CSV export, and advanced row selection.
The npm package @abaktiar/datagrid receives a total of 0 weekly downloads. As such, @abaktiar/datagrid popularity was classified as not popular.
We found that @abaktiar/datagrid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.