react-pro-tablex v1.1.8
π React Custom Table
A highly customizable and reusable table component for React applications, featuring pagination, filtering, sorting, and export functionality.
π Features
β
Fully customizable via props and styles
β
Pagination with support for dynamic page fetching
β
Search & Filtering with instant updates
β
Sorting support for multiple columns
β
Copyable Cells for selected columns
β
Localization Support for different languages
β
Export to CSV functionality
β
Responsive & Accessible design
πΊ Installation
Install via npm or yarn:
npm install react-custom-table
# or
yarn add react-custom-table
π Basic Usage
Import the table component and use it in your project:
import React from "react";
import Table from "react-custom-table";
const columns = ["name", "email"];
const columnDisplayNames = ["Name", "Email"];
const data = [
{ name: "John Doe", email: "john@example.com" },
{ name: "Jane Smith", email: "jane@example.com" }
];
function App() {
return (
<Table
columns={columns}
columnDisplayNames={columnDisplayNames}
data={data}
title="User List"
enablePagination={true}
/>
);
}
export default App;
π¨ Customization Options
π οΈ Available Props
Prop | Type | Default | Description |
---|---|---|---|
columns | array | [] | List of column keys in the dataset |
columnDisplayNames | array | [] | User-friendly names for columns |
data | array | [] | Data to display in the table |
title | string | "" | Title of the table |
enablePagination | boolean | false | Enables pagination |
currentPaginationPage | number | 0 | Controls pagination state |
paginationCallback | function | null | Custom function for fetching paginated data |
hasNextPage | boolean | false | Determines if more pages exist |
enableFilter | boolean | false | Enables search filtering |
copyableColumns | array | ["email", "id"] | Columns that allow copying |
onExport | function | null | Callback for CSV export |
enableExport | boolean | false | Shows an export button |
locale | object | {} | Allows localization of labels |
π Localization Support
The table supports multiple languages via the locale
prop:
<Table
locale={{
filterLabel: "Filtrar",
noRecords: "No hay registros para mostrar.",
previous: "Anterior",
next: "Siguiente",
itemsPerPageLabel: "Mostrar Γtems",
exportButtonLabel: "Exportar CSV"
}}
/>
ποΈ Styling & Theming
You can override the default styles via CSS Modules:
/* Custom styles in your CSS */
.customTable .tableContainer {
background-color: #f8f9fa;
border-radius: 10px;
padding: 20px;
}
Use the tableStyle
, columnHeaderStyle
, and tableRowStyle
props for inline styling.
π Export to CSV
To enable exporting, provide an onExport
function:
const handleExport = (filteredData, columns, columnDisplayNames) => {
console.log("Exporting data:", filteredData);
};
<Table data={data} onExport={handleExport} enableExport={true} />;
π₯ Advanced Example (With Actions)
<Table
columns={["name", "email", "status"]}
columnDisplayNames={["Name", "Email", "Status"]}
data=[
{ name: "Alice", email: "alice@example.com", status: "Active" },
{ name: "Bob", email: "bob@example.com", status: "Inactive" }
]
hasActionColumn={true}
hasViewColumn={true}
onEditClick={(row) => console.log("Editing:", row)}
onDeleteClick={(row) => console.log("Deleting:", row)}
onViewClick={(row) => console.log("Viewing:", row)}
enablePagination={true}
/>
π License
This project is licensed under the MIT License.
π οΈ Contributing
Pull requests and feature suggestions are welcome!
Feel free to fork the repository and create a PR.
π© Support & Feedback
If you encounter any issues or have questions, open an issue on GitHub.
π GitHub Repository: https://github.com/mohamed-aje/react-custom-table