Table Component

The Table component provides a fully responsive and highly customizable data table system. Optimized for dark mode, with inline styles, className overrides, and flexible structure using head, body, rows, and cells.

Import Component From Library

javascript
1import { Table, THead, TBody, TRow, TH, TD } from "@neuctra/ui";

Basic Usage Code

Start with a simple table. The component provides responsive and customizable data tables with striped rows, borders, and styling.

tsx
1import { Table, THead, TBody, TRow, TH, TD } from '@neuctra/ui';
2
3function BasicExample() {
4  return (
5    <Table striped bordered>
6      <THead>
7        <TRow>
8          <TH>Name</TH>
9          <TH>Email</TH>
10        </TRow>
11      </THead>
12      <TBody>
13        <TRow>
14          <TD>John Doe</TD>
15          <TD>[email protected]</TD>
16        </TRow>
17        <TRow>
18          <TD>Jane Smith</TD>
19          <TD>[email protected]</TD>
20        </TRow>
21      </TBody>
22    </Table>
23  );
24}

Basic Example

Responsive Table

ProductCategoryPriceStockStatusRating
MacBook ProLaptop$200012Available4.8
iPhone 15Mobile$120030Available4.7
AirPods ProAccessories$25050In Stock4.6
iPad AirTablet$9008Limited4.5

Custom Styling

NameRoleStatus
SarahDeveloperActive
MikeDesignerActive

Props Reference

Table

PropTypeDefaultDescription
responsivebooleantrueEnable horizontal scrolling on narrow screens.
stripedbooleanfalseAlternate row backgrounds in the body.
hoverablebooleantrueApply hover state styling to rows.
borderedbooleanfalseAdd row border separators.
densebooleanfalseUse smaller cell padding for compact layouts.
classNamestring—Custom wrapper container classes.
styleCSSProperties—Custom wrapper inline styles.
tableClassNamestring—Custom class for the inner table element.
tableStyleCSSProperties—Custom inline styles for the inner table element.

THead

PropTypeDefaultDescription
childrenReactNode—Header rows and cells.
classNamestring—Custom class names for the header section.
styleCSSProperties—Custom inline styles for the header section.
borderedboolean—Pass border state into header rows.

TBody

PropTypeDefaultDescription
childrenReactNode—Body rows and cells.
classNamestring—Custom class names for the body section.
styleCSSProperties—Custom inline styles for the body section.
stripedboolean—Forward striped state to child rows.
hoverableboolean—Forward hoverable state to child rows.
borderedboolean—Forward bordered state to child rows.

TRow

PropTypeDefaultDescription
childrenReactNode—Row cells and nested content.
classNamestring—Custom class names for the row.
styleCSSProperties—Custom inline styles for the row.
onClick() => void—Add a click handler to the row.
stripedboolean—Set striped state on this row.
hoverableboolean—Enable hover styling for this row.
borderedboolean—Show the row border in the row.
indexnumber0Row index used for striped styling.

TH

PropTypeDefaultDescription
childrenReactNode—Header cell content.
classNamestring—Custom classes for the header cell.
styleCSSProperties—Custom inline styles for the header cell.
borderedboolean—Apply bottom border to the header cell.
densebooleanfalseReduce cell padding for compact display.

TD

PropTypeDefaultDescription
childrenReactNode—Cell content.
classNamestring—Custom classes for the cell.
styleCSSProperties—Custom inline styles for the cell.
densebooleanfalseReduce cell padding for compact display.

Pro Tips

  • Use responsive to enable horizontal scrolling on small screens.
  • Combine striped and hoverable for better readability.
  • Use dense mode to display more data in limited space.
  • Override individual cell styles using className on TH and TD.
  • Add row click handlers with onClick on TRow component.
  • Combine with pagination components for large datasets.
  • Keep columns minimal for better UX on small screens.

Frequently Asked Questions

How do I install and import the Table component?

Install the @neuctra/ui package, then import it with: import { Table } from "@neuctra/ui";

Can I customize the Table component's appearance?

Yes. Table accepts a className prop for custom Tailwind CSS classes, so you can adjust spacing, layout, and styling without overriding the component internals.

Is the Table component accessible?

Table is built with semantic HTML and standard ARIA attributes, and supports keyboard navigation and focus states out of the box, so it works well with screen readers and keyboard-only users.

Built with React, Tailwind CSS & TypeScript.