Table

Tables are used to organize and present data efficiently in applications. They provide features like sorting, filtering, pagination, and various display modes to handle complex data representations effectively.

TypeResource
DesignFigma
WebWeb Storybook
CodeGitlab

Usage

import { Avatar } from 'bio-bind-ui';
import { Table } from 'bio-bind-ui';
 
function MyComponent() {
  return (
    <Table
      columns={[
        {
          header: 'Name',
          accessorKey: 'name',
        },
        {
          header: 'Age',
          accessorKey: 'age',
        },
      ]}
      data={[
        { name: 'John Doe', age: 30 },
        { name: 'Jane Smith', age: 25 },
      ]}
    />
  );
}

Examples

Default Table

Basic table with standard configuration.

With Pagination

Table with server-side pagination support.

With Filtering

Table with column filtering capabilities.

With Row Selection

Table with selectable rows.

With Variant Colored

Table with variant colored

With Infinite Scroll

Table with infinite scroll loading.

Props

PropTypeDefaultDescription
variant"default" | "neutral" | "colored""default"Visual style of the table
mode"light" | "dark""light"Theme mode of the table
stripedbooleanfalseEnables alternating row colors
columnsColumnDef<unknown, unknown>[]RequiredColumn definitions
dataunknown[]RequiredTable data
showPaginationbooleanfalseShows pagination controls
paginationOptionsPaginationOptions-Server-side pagination config
clientbooleanfalseEnables client-side operations
loadingbooleanfalseShows loading state
selectedRowbooleanfalseEnables row selection
infinitybooleanfalseEnables infinite scrolling
emptyTextstring"No data available"Text for empty state
expandedRowbooleanfalseEnables expandable rows
subComponent(rowData: any) => ReactNode-Renders expanded row content
onSorting(sort: ColumnSort[]) => void-Sorting change callback
onFilter(filter: ColumnFilter[]) => void-Filter change callback
onSelectedRow(selected: any[]) => void-Selection change callback

Column Definition

Columns are defined using the ColumnDef type from @tanstack/react-table. Here are the key properties:

interface ColumnDef {
  header: string;
  accessorKey: string;
  size?: number;
  enableSorting?: boolean;
  enableGlobalFilter?: boolean;
  meta?: {
    filterVariant: 'text' | 'select' | 'range';
    options?: Array<{ label: string; value: string | number }>;
  };
}

Pagination Options

Configuration for server-side pagination:

interface PaginationOptions {
  showPerPage: boolean;
  limitOption?: number[];
  totalPage: number;
  page: number;
  pageSize: number;
  onChangePage: (page: number) => void;
  onChangeLimit: (limit: number) => void;
}

Filter Types

The table supports three types of filters:

  1. Text Filter: Free text search
  2. Select Filter: Dropdown selection from predefined options
  3. Range Filter: Date range selection

Styling

The table supports two themes (light and dark) and three variants:

  • default: Standard table design
  • neutral: Minimalist design
  • colored: Enhanced visual hierarchy with colored rows

Accessibility

The table component is built with accessibility in mind:

  • Proper ARIA labels
  • Keyboard navigation support
  • Screen reader friendly markup
  • High contrast mode support

Best Practices

  1. Performance

    • Use client-side operations for small datasets
    • Implement server-side operations for large datasets
    • Enable infinite scroll for large datasets with frequent updates
  2. Responsive Design

    • Consider column visibility on different screen sizes
    • Use appropriate column widths
    • Implement horizontal scrolling for many columns
  3. Data Loading

    • Show loading state during data fetching
    • Provide meaningful empty states
    • Handle errors gracefully
  4. Filtering

    • Choose appropriate filter types for each column
    • Implement debouncing for text filters
    • Provide clear filter indicators
BIND © Biofarma Innovate Next-level Design .