Skip to main content
Version: 1.0.2

Table

Overview

The Table component provides a way to display data in a structured format with support for sorting, pagination, and customizable styling. It's built on top of Radix UI's table primitives for accessibility and performance.

Preview

Name
Email
Status
John Doe
john@example.com
Active
Jane Smith
jane@example.com
Inactive
Bob Johnson
bob@example.com
Active
Alice Johnson
alice@example.com
Active

Installation

npx @mindfiredigital/ignix-ui add table

Usage

Basic Usage

import { Table } from './components/ui';

function MyTable() {
const [sortConfig, setSortConfig] = useState({ key: 'name', direction: 'asc' });

const data = [
{ id: 1, name: 'John Doe', email: 'john@example.com' },
{ id: 2, name: 'Jane Smith', email: 'jane@example.com' },
];

const handleSort = (key, direction) => {
setSortConfig({ key, direction });
// Implement sorting logic
};

return (
<Table
headings={[
{ label: 'Name', key: 'name', sort: 'asc' },
{ label: 'Email', key: 'email', sort: 'asc' },
]}
data={data}
applySort={handleSort}
/>
);
}

With Pagination

function PaginatedTable() {
const [currentPage, setCurrentPage] = useState(1);
const totalPages = 5;

// ... rest of your component code ...

return (
<Table
// ... other props ...
currentPage={currentPage}
totalPages={totalPages}
onPageChange={setCurrentPage}
/>
);
}

Variants

Name
Email
Status
John Doe
john@example.com
Active
Jane Smith
jane@example.com
Inactive
Bob Johnson
bob@example.com
Active
Alice Johnson
alice@example.com
Active