🚀ReacUI is currently in Beta. We're actively improving it! ❣️

Table

A flexible table component for displaying structured data

NameEmailRole
John Doejohn@example.comAdmin
Jane Smithjane@example.comEditor

Installation

The Table component is part of the ReacUI library. Install the package to use it in your project.

npm install reacui

Import

Import the Table component into your React component.

import { Table } from 'reacui';

Basic Usage

A simple table with headers and body rows.

ProductPrice
Product A$100
Product B$200
<Table>
  <Table.Header>
    <Table.Row>
      <Table.HeaderCell>Product</Table.HeaderCell>
      <Table.HeaderCell>Price</Table.HeaderCell>
    </Table.Row>
  </Table.Header>
  <Table.Body>
    <Table.Row>
      <Table.Cell>Product A</Table.Cell>
      <Table.Cell>$100</Table.Cell>
    </Table.Row>
    <Table.Row>
      <Table.Cell>Product B</Table.Cell>
      <Table.Cell>$200</Table.Cell>
    </Table.Row>
  </Table.Body>
</Table>

Table Structure

The Table component is composed of several subcomponents: Header, Body, Row, HeaderCell, and Cell.

<Table>
  <Table.Header>
    <Table.Row>
      <Table.HeaderCell>Column 1</Table.HeaderCell>
      <Table.HeaderCell>Column 2</Table.HeaderCell>
    </Table.Row>
  </Table.Header>
  <Table.Body>
    <Table.Row>
      <Table.Cell>Data 1</Table.Cell>
      <Table.Cell>Data 2</Table.Cell>
    </Table.Row>
  </Table.Body>
</Table>

Custom Styling

Apply custom styles to any part of the table using the className prop.

NameStatus
Project AlphaActive
Project BetaIn Review
<Table>
  <Table.Header className="bg-primary-100 dark:bg-primary-900">
    <Table.Row>
      <Table.HeaderCell className="text-primary-800 dark:text-primary-300">Name</Table.HeaderCell>
      <Table.HeaderCell className="text-primary-800 dark:text-primary-300">Status</Table.HeaderCell>
    </Table.Row>
  </Table.Header>
  <Table.Body>
    <Table.Row className="hover:bg-primary-50 dark:hover:bg-primary-900/50">
      <Table.Cell>Project Alpha</Table.Cell>
      <Table.Cell>
        <Badge variant="success" size="sm">Active</Badge>
      </Table.Cell>
    </Table.Row>
    <Table.Row className="hover:bg-primary-50 dark:hover:bg-primary-900/50">
      <Table.Cell>Project Beta</Table.Cell>
      <Table.Cell>
        <Badge variant="warning" size="sm">In Review</Badge>
      </Table.Cell>
    </Table.Row>
  </Table.Body>
</Table>

API Reference

The following props are available for the Table components.

ComponentPropTypeDefaultDescription
TablechildrenReactNode-The table content.
TableclassNamestring''Additional CSS classes.
Table.HeaderchildrenReactNode-The table header content.
Table.HeaderclassNamestring''Additional CSS classes.
Table.BodychildrenReactNode-The table body content.
Table.BodyclassNamestring''Additional CSS classes.