Componentsv2.189.1
Iconsv1.19.0
MCPv0.8.62
Tokensv0.34.3

A container for displaying display data in a tabular format.

A table consists of the following components:

  • Table
    • The container, renders a table tag.
  • TableThead
    • The thead tag to wrap table headers.
  • TableTbody
    • The tbody tag to wrap the table's main data.
  • TableTr
    • The tr tag - a table row.
  • TableTh
    • The th tag - a table header.
  • TableTd
    • The td tag - a table cell.

Importing

The components can be imported via:

import {
	Table,
	TableThead,
	TableTbody
	TableTr,
	TableTh,
	TableTd
} from '@customerio/pluma-components/react';

Usage

To build a table, use the Pluma components like you would the native HTML elements. For example:

Loading editor

Note: It is required to provide a caption argument, which renders a visually hidden caption tag within the table. This caption is used by assistive technologies to provide context to the table.

TableTh

The TableTh component will automatically receive a scope attribute of col or row, depending on whether it is nested within Thead or Tbody:

Loading editor

Variants

The table can render in a few differently styled variants.

Borderless

isBorderless will remove borders between table rows:

Loading editor

Striped

isStriped will apply alternating background colors to rows:

Loading editor

Hover style

shouldHighlightOnHover will apply a background color when hovering over a row:

Loading editor

Sometimes, you may need to conditionally enable the hover style only on specific rows. In this case, you can pass the shouldHighlightOnHover prop to the TableTr component directly:

Loading editor

Fixed layout

The component accepts a layout prop, which can be set to fixed to set table-layout: fixed on the table.

Loading editor

Clickable headers

The TableTh component accepts an onClick prop. When present, the header will render a button, which will call the provided callback when clicked.

Additionally, the isActive prop to apply a different text color to the header, to indicate that the column is currently "active".

These props can be used when making tables sortable, and clicking headers should invoke the sorting functionality.

Loading editor

Note: The table component itself does not perform any sorting at this time. These props are utilities to make it easier to customize the table to include sorting.

API

PlumaTable extends Box

A caption for the table for assistive technologies, but hidden visually.

Whether to disable the border style between table rows

Whether to render table rows with alternating background colors

Default:auto

The layout of the table

Whether hovering over the rows should highlight them (change their background color)

Whether this column is active (for example, when sorting on this column). Changes the color of the column header's text.

Whether the cell is clickable. When provided, the cell will render a button, and will have additional hover styles applied. Can be used when implementing click-to-sort functionality, for example.

Whether to disable the border style on this row

Whether hovering over this row should highlight it (change its background color)

Whether the cell should have extra padding depending on nesting level.