Table Component

The Table component is a versatile and customizable table that supports sorting, filtering, and exporting data. It provides various features to enhance data presentation and interaction.

Props

PropTypeDefaultDescription
tableConfigTableConfigrequiredConfiguration object for the table
isSerializedbooleantrueWhether to show row numbers
size"xs" | "s" | "m" | "l" | "xl""m"Sets the size of the table
headerbooleantrueWhether to show the table header
titlestring""Title of the table
printSizestring"A4 landscape"Page size for printing
sumbooleanfalseWhether to show sum row for numeric columns

Usage

import { Table } from 'knoxui-react';

const tableConfig = {
  data: [
    { id: 1, name: 'John Doe', age: 30, city: 'New York' },
    { id: 2, name: 'Jane Smith', age: 25, city: 'Los Angeles' },
    { id: 3, name: 'Bob Johnson', age: 35, city: 'Chicago' },
  ],
  columns: [
    { key: 'id', header: 'ID' },
    { key: 'name', header: 'Name' },
    { key: 'age', header: 'Age', dataType: 'int' },
    { key: 'city', header: 'City' },
  ],
};

<Table tableConfig={tableConfig} />

Examples

Basic Usage

#IDNameAgeCity
11John Doe30New York
22Jane Smith25Los Angeles
33Bob Johnson35Chicago

Custom Size

#IDNameAgeCity
11John Doe30New York
22Jane Smith25Los Angeles
33Bob Johnson35Chicago

With Title and Sum

Employee Data
#IDNameAgeCity
11John Doe30New York
22Jane Smith25Los Angeles
33Bob Johnson35Chicago

Without Header and Serialization

IDNameAgeCity
1John Doe30New York
2Jane Smith25Los Angeles
3Bob Johnson35Chicago

Features

  • Sorting: Click on column headers to sort the data
  • Filtering: Use the search inputs to filter data in each column
  • Exporting: Export data to Excel or PDF formats
  • Responsive: Adapts to different screen sizes
  • Customizable: Adjust size, appearance, and functionality