Skip to main content
Version: Next

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}
/>
);
}

Custom Styling

<Table
// ... other props ...
variant="ghost"
accentColor="blue"
radius="large"
className="custom-table"
style={{ '--accent-9': 'var(--blue-9)' }}
/>

Best Practices

  • Always provide a unique key for each column in the headings array
  • Implement proper error handling for pagination
  • Use the applySort callback to handle sorting logic in your parent component
  • Consider using the variant prop to match your application's design system
  • For large datasets, implement virtualization for better performance