New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

twdtable

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twdtable

A modern, lightweight, and customizable React DataTable component built with Vite and Tailwind CSS. Designed for efficiency, it supports sorting, filtering, pagination, and more.

latest
Source
npmnpm
Version
1.1.12
Version published
Maintainers
1
Created
Source

📊 TwdTable DataTable Module

A powerful and customizable React data table component built with Vite, TypeScript, and Tailwind CSS.

✨ Features

  • 📌 Fully customizable
  • 📊 Supports sorting, filtering, and pagination
  • 🎨 Tailwind CSS support for easy styling
  • ⚡ Optimized for performance

🚀 Installation

Install the package via npm:

npm install twdtable

Or with yarn:

yarn add twdtable

🚀 Usage

import { TwdTable } from "twdtable";
import "twdtable/dist/twdtable.css";
const App = () => {
  const data = {
    columns: [
      {
        field: "id",
        label: "ID",
        enableSorting: false, // Disable sorting
        enableHiding: false, // Disable hiding
        enableSelect: true, // Enable Row Selection
      },
      {
        field: "name",
        label: "Name",
        className: {
	 row_txt: "text-red-500"
	}, // Each columns have support className
      },
      {
        field: "email",
        label: "Email",
      },
      {
        label: "actions",
        actions: [
          {
            label: "Edit",
            onClick: (id, doc) => {},
          },
          {
            label: "Delete",
            split: true,
            onClick: (id, doc) => {},
            dialog: {
              status: true,
              title: "Delete Item",
              description: "Are you sure you want to delete this item? This action cannot be undone.",
              button: "Confirm Delete",
            },
          },
        ],
      },
    ],
    rows: [
      { id: 1, name: "John Doe", email: "john@example.com" },
      { id: 2, name: "Jane Doe", email: "jane@example.com" },
    ],
  };

  return (
    <>
      <TwdTable
        data={data}
        selectable
        fullPagination
        handlePageLimitChange={(page, limit) => {}}
        handleFilterChange={(filter, page, limit) => {}}
        columnCallBack={(type, data) => {}}
        flOption={{ export: true, delete: true, send: true }}
        defaultLimit={10}
        selectOptions={{
          Age: [
            { label: "20", value: "20", _id: "1" },
            { label: "30", value: "30", _id: "2" },
          ],
          Class: [
            { label: "10th", value: "10", _id: "1" },
            { label: "12th", value: "12", _id: "2" },
          ],
        }}
	classNames={{
	 	pgn: "bg-red-500 text-blue-500"
	}}
      />
    </>
  );
};

export default App;

🔧 Props

PropsTypeDescription
state{ filter: object, setFilter: (e: Record<string, any>) => void;}Table state, including filter values and update function
flOption{ export: boolean, delete: boolean, send: boolean}Options for exporting, deleting, and seding data
limitsnumber[]Available page limit options
defaultLimitnumberDefault page limit
apibooleanenable API-based data loading, its true by default
stripedbooleanadd striped row styling
selectablebooleanenable row selection
fullPaginationbooleanShow full pagination controls
columnCallBack(type: string, data: {field: string, sort: string} or {_id: string, data: Record<any, any>}) => void;})Callback function for column and filter interactions
handlePageLimitChange(page: number, limit: number) => void;Callback function for page and limit changing
handleFilterChange(filter: any, page: number, limit: number) => void;CallBack function for filtering changes
smbooleanEnable small table style
loadingbooleanshow loading indicator
cancelLoadingbooleanCancel loading indicator
countnumbertotal data count
searchFieldstringIf api is false use this to filter inputs
selectOptionsArray<Record<string, any>>Options for filter
classNamesRecord<string, any>style
data{ columns: Columns[], rows: Array<Record<string, any>>}
paginationbooleanhide paginatio section
filterOptionsbooleanhide filter options in header
headerbooleanhide header section
serialNumberboolean
filterPlaceholderstringyou can change filter input placeholder value

Note: The handlePageLimitChange and handleFilterChange functions are automatically invoked when the table data is accessed ( similar to how useEffect behaves ). therefore, you don't need to mannually call these functions using useEffect.

Note: When header or filterOptions is set to false. handleFilterChange is not invoked automatically. You must use useEffect to manually load the data.

Similarly, when pagination set to false. handlePageLimitChange is not triggered automatically.

Columns[]

{
	field: string;
	label: string;

	className?: Record<string, any>;

	enableSorting?: boolean;
	enableHiding?: boolean;
	enableSelect?: boolean;

	type?: "date";

	actions?: {
		label: string;
		show: boolean, // When set to true, the action labels will be displayed in the table row header.
		dropdown: boolean,
		icon?: element, // When dropdown is set to true, provide the icons to be displayed in the column data.
		onClick: (id, doc) => void;
		split?: boolean;
		dialog?: {
			status: boolean;
			title: string;
			description: string;
			button: string;
		};
	}[];
}

🎨 Customization

classNamesDescription
dio_boxaction dialog box
dio_titleaction dialog box titile
dio_descaction dialog box description
dio_btnaction dialog box button
row_ckheader column check box styling
row_txtheader column text styling
fl_optionfilter option styling
fl_on_menufilter option dropmenu styling
fl_on_itemfilter option dropmenu item styling
fl_sptfilter option dropmenu splitter styling
fl_mn_inputfilter input styling
pgnpagination style
pgn_txtpagination text styling
pgn_menupagination limit menu styling
pgn_itempagination limit menu item styling
act_menucolumn hiding action menu styling
act_itemcolumn hiding action menu item styling
act_btncolumn hiding action button styling
fl_inputcolumns filter input styling
fl_act_btncolumn filter button styling
fl_act_rbtncolumns filter reset button styling
clm_txtcolumn header text styling
clm_menucolumn header menu styling
clm_itemcolumn header menu item styling
clm_iconcolumn header menu item icon styling
tableHeadertable header styling
tableBodytable body styling
fl_on_menu_clrfilter option dropmenu clear btn styling

🚀 Enjoy using TwdTable! If you like this project, consider giving it a ⭐ on GitHub!

Keywords

data-table

FAQs

Package last updated on 22 May 2025

Did you know?

Socket

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.

Install

Related posts