Package Exports
- react-datagrid-component
- react-datagrid-component/dist/index.es.js
- react-datagrid-component/dist/index.umd.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-datagrid-component) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
FluentGrid - Advanced React Data Grid Component
A powerful, customizable data grid component built with React, TypeScript, and TanStack Table v8. Features include column resizing, pinning, filtering, sorting, pagination, cell editing, and theme support.
🚀 Features
- 📊 Advanced Data Grid: Built on TanStack Table v8 for maximum performance
- 🎨 Theme Support: Light/dark mode with custom primary colors
- 📏 Column Management: Resize, pin, reorder, and hide columns
- 🔍 Smart Filtering: Type-specific filters with advanced operators
- ✏️ Cell Editing: Inline editing with validation and large text support
- 📱 Responsive Design: Mobile-friendly with adaptive layouts
- ⚡ Virtual Scrolling: Optimized for large datasets
- 🎯 Bulk Actions: Multi-select with bulk operations
- 📤 Import/Export: CSV and Excel support
- 🔧 Highly Customizable: Extensive props and styling options
📦 Installation
npm install react-datagrid-component
# or
yarn add react-datagrid-component
# or
pnpm add react-datagrid-component🎨 Including Styles
Important: You must import the CSS file to use the component properly:
import 'react-datagrid-component/dist/style.css';The CSS file includes:
- Tailwind CSS utilities
- Component-specific styles
- Theme-aware styling
- Responsive design
- Accessibility features
🎯 Quick Start
import { DataGridTable } from 'react-datagrid-component';
import 'react-datagrid-component/dist/style.css'; // Include styles
const columns = [
{
id: 'name',
header: 'Name',
accessorKey: 'name',
type: 'text',
editable: true,
},
{
id: 'age',
header: 'Age',
accessorKey: 'age',
type: 'number',
sortable: true,
},
{
id: 'status',
header: 'Status',
accessorKey: 'status',
type: 'badge',
options: [
{ label: 'Active', value: 'active' },
{ label: 'Inactive', value: 'inactive' },
],
},
];
const data = [
{ id: 1, name: 'John Doe', age: 30, status: 'active' },
{ id: 2, name: 'Jane Smith', age: 25, status: 'inactive' },
];
function App() {
return (
<DataGridTable
data={data}
columns={columns}
tableName="Users"
onDataChange={(newData) => console.log('Data changed:', newData)}
/>
);
}📚 API Reference
DataGridTable Props
| Prop | Type | Default | Description |
|---|---|---|---|
data |
T[] |
- | Array of data objects |
columns |
DataGridColumn<T>[] |
- | Column definitions |
tableName |
string |
- | Display name for the table |
loading |
boolean |
false |
Loading state |
error |
string |
- | Error message to display |
onDataChange |
(data: T[]) => void |
- | Callback when data changes |
onRowEdit |
(row: T, field: keyof T, value: any) => Promise<void> |
- | Row edit callback |
onRowDelete |
(rows: T[]) => Promise<void> |
- | Row delete callback |
onExport |
(data: T[], format: 'csv' | 'xlsx') => void |
- | Export callback |
onImport |
(data: T[]) => void |
- | Import callback |
pagination |
PaginationConfig |
{ pageSize: 25, showSizeSelect: true, pageSizeOptions: [10, 25, 50, 100] } |
Pagination settings |
selection |
SelectionConfig |
{ enabled: true } |
Row selection settings |
globalSearch |
GlobalSearchConfig |
{ enabled: true, placeholder: "Search across all columns..." } |
Global search settings |
theming |
ThemingConfig |
{ enabled: true, defaultTheme: 'light' } |
Theme settings |
className |
string |
- | Additional CSS classes |
apiConfig |
DataGridApiConfig |
- | API configuration for CRUD operations |
Column Types
| Type | Description | Features |
|---|---|---|
text |
Text input | Basic text editing, filtering |
number |
Numeric input | Number validation, range filtering |
select |
Dropdown selection | Predefined options, multi-select |
date |
Date picker | Date range filtering, calendar |
badge |
Status badges | Color-coded status display |
image |
Image display | Thumbnail preview |
chart |
Chart visualization | Data visualization |
largeText |
Large text editor | Multi-line editing, popup editor |
Column Properties
| Property | Type | Description |
|---|---|---|
id |
string |
Unique column identifier |
header |
string |
Column header text |
accessorKey |
keyof T |
Data field key |
type |
ColumnType |
Column type for rendering |
editable |
boolean |
Enable cell editing |
filterable |
boolean |
Enable column filtering |
sortable |
boolean |
Enable column sorting |
pinnable |
boolean |
Enable column pinning |
width |
number |
Column width in pixels |
minWidth |
number |
Minimum column width |
maxWidth |
number |
Maximum column width |
options |
Array<{label: string, value: any}> |
Options for select/badge types |
🎨 Styling
The component uses Tailwind CSS for styling and includes comprehensive CSS classes. You can customize the appearance in several ways:
1. CSS Import (Required)
import 'react-datagrid-component/dist/style.css';2. Theme Variables
Override CSS custom properties for theming:
:root {
--primary: 20 14.3% 4.1%;
--primary-foreground: 60 9.1% 97.8%;
--background: 0 0% 100%;
--foreground: 20 14.3% 4.1%;
--muted: 210 40% 96%;
--muted-foreground: 215.4 16.3% 46.9%;
--border: 214.3 31.8% 91.4%;
--ring: 215 20.2% 65.1%;
/* ... more variables */
}3. Custom Classes
Pass additional CSS classes via the className prop:
<DataGridTable
data={data}
columns={columns}
className="my-custom-grid bg-blue-50"
/>4. Component-Specific Classes
The CSS includes utility classes for specific components:
.fluent-grid-badge.active { /* Active badge styles */ }
.fluent-grid-avatar { /* Avatar styles */ }
.fluent-grid-progress { /* Progress bar styles */ }
.fluent-grid-search { /* Search input styles */ }5. Tailwind Configuration
Extend your Tailwind configuration to include the component's design tokens:
// tailwind.config.js
module.exports = {
content: [
'./src/**/*.{js,ts,jsx,tsx}',
'node_modules/react-datagrid-component/dist/**/*.js'
],
theme: {
extend: {
colors: {
// Your custom colors
}
}
}
}🔧 Advanced Usage
Custom Cell Renderers
import { CellRenderer } from 'fluent-grid';
const CustomCell = ({ value, row, column, isEditing, onSave, onCancel }) => {
if (isEditing) {
return (
<input
value={value}
onChange={(e) => onSave(e.target.value)}
onBlur={onCancel}
autoFocus
/>
);
}
return <span>{value}</span>;
};
const columns = [
{
id: 'custom',
header: 'Custom',
accessorKey: 'custom',
cell: CustomCell,
},
];API Integration
const apiConfig = {
fetchUrl: 'https://api.example.com/users',
updateUrl: 'https://api.example.com/users/:id',
deleteUrl: 'https://api.example.com/users',
method: 'PATCH',
};
<DataGridTable
data={data}
columns={columns}
apiConfig={apiConfig}
onRowEdit={async (row, field, value) => {
// Custom edit logic
await updateUser(row.id, { [field]: value });
}}
/>Custom Filtering
const columns = [
{
id: 'status',
header: 'Status',
accessorKey: 'status',
type: 'select',
filterable: true,
options: [
{ label: 'Active', value: 'active' },
{ label: 'Inactive', value: 'inactive' },
{ label: 'Pending', value: 'pending' },
],
},
];📦 Exported Components
DataGridTable- Main data grid componentThemePicker- Theme selection componentFileUpload- Import/export componentColumnVisibility- Column visibility toggleColumnFilter- Individual column filterAppliedFilters- Active filters displayBulkActions- Bulk operations componentTablePagination- Pagination componentCellRenderer- Cell rendering utilitiesDensitySelector- Row density selectorPinnedColumnsIndicator- Pinned columns displayLargeTextEditor- Large text editing dialogResizablePopup- Resizable popup component
🔗 Dependencies
Peer Dependencies
react^18.0.0react-dom^18.0.0@tanstack/react-table^8.0.0
Required Dependencies
@radix-ui/*- UI primitiveslucide-react- Iconsdate-fns- Date utilitiesreact-day-picker- Date pickerclass-variance-authority- Component variantsclsx- Conditional classestailwind-merge- Tailwind class merging
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
📄 License
MIT License - see LICENSE file for details
🔧 Troubleshooting
CSS Import Issues
If you encounter an error like:
Failed to resolve import "react-datagrid-component/dist/style.css"Solution: Make sure you're importing the CSS file correctly:
import 'react-datagrid-component/dist/style.css';Common issues:
- Missing CSS import: Always import the CSS file after installing the package
- Build tool configuration: Ensure your bundler (Vite, Webpack, etc.) can handle CSS imports
- Package version: Make sure you're using the latest version of the package
Styling Issues
If the component doesn't look styled properly:
- Check CSS import: Ensure the CSS file is imported
- Tailwind CSS: Make sure Tailwind CSS is installed and configured in your project
- CSS variables: Verify that your CSS custom properties are defined
Build Issues
If you encounter build errors:
- Peer dependencies: Ensure all peer dependencies are installed
- TypeScript: Make sure TypeScript is configured to handle the package types
- Module resolution: Check that your bundler can resolve ES modules
🆘 Support
- 📖 Documentation
- 🐛 Issues
- 💬 Discussions