1.1.8 β€’ Published 6 months ago

react-pro-tablex v1.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

πŸ’Š 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

PropTypeDefaultDescription
columnsarray[]List of column keys in the dataset
columnDisplayNamesarray[]User-friendly names for columns
dataarray[]Data to display in the table
titlestring""Title of the table
enablePaginationbooleanfalseEnables pagination
currentPaginationPagenumber0Controls pagination state
paginationCallbackfunctionnullCustom function for fetching paginated data
hasNextPagebooleanfalseDetermines if more pages exist
enableFilterbooleanfalseEnables search filtering
copyableColumnsarray["email", "id"]Columns that allow copying
onExportfunctionnullCallback for CSV export
enableExportbooleanfalseShows an export button
localeobject{}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

1.1.8

6 months ago

1.1.7

6 months ago

1.1.6

6 months ago

1.1.5

6 months ago

1.1.4

6 months ago

1.1.2

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago