Table

Tables display data-centric information.

import { Table } from '@cerberus/react'

Usage

The Table component is a controlled component that can be used to display tabular data. It can be used in a group with other tables to allow for multiple selections.

Basic table example
ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Sizes

The Table.Root component supports different sizes for its cells. You can set the size of the table using the size prop. The available sizes are sm, md, and lg. The default size is md.

Table with different cell sizes
Small
Small
Table with different cell sizes
Medium
Medium
Table with different cell sizes
Large
Large

Decoration

The Table.Root component supports different decorations for its rows. You can set the decoration of the table using the decoration prop. The available decorations are default and zebra.

Table with default decorations
Default
one
two
three
Table with zebra decorations
Zebra
one
two
three

Sticky

The Table.Root component supports a sticky prop, which makes the table header sticky. This is useful for long tables where you want to keep the header visible while scrolling.

Better find a mop, it's getting sticky...
ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Clickable

The Table.HeaderCol component supports a Table.Trigger, which renders a button element. This allows you to create clickable headers for sorting or other actions.

Clickable table
Name
Jane Doe25
John Doe30

Primitives

You can utilize the primitive components to customize the table.

ComponentDescription
TableRootThe table container component.
TableElThe table component.
CaptionThe caption component.
TheadThe table header component.
ThThe table header cell component.
TbodyThe table body component.
TrThe table row component.
TdThe table cell component.
TfootThe table footer component.
TableTriggerThe table trigger component.
Customized table
Cerberus FamilyAlias
CerberusThe Three-Headed Dog
HadesGod of the Underworld
PersephoneQueen of the Underworld
CharonThe Ferryman
CerberusThe Guardian of the Underworld
ThanatosGod of Death

API

Props

The Table component is an abstraction of the primitives and accepts the following props:

NameDefaultDescription
captionThe accessible caption of the Table.
sizemdThis cell size of the Table.
decorationdefaultThe decoration of the Table.
stickyfalseIf true, the table header will be sticky.

Table component parts

The Table API is an Object containing the full family of abstracted components.

NameDescription
RootAn abstraction of the TableRoot, TableEl, and Caption.
HeaderThe table header component.
HeaderColThe table header cell component.
BodyThe table body component.
RowThe table row component.
CellThe table cell component.
FooterThe table footer component.
TriggerThe optional table header col trigger component.

Parts

The TableParts API is an Object containing the full family of components.

NameDescription
RootThe TableRoot component which is the container of the table.
TableThe TableEl component which is the table element.
CaptionThe Caption component which is the caption of the table.
HeaderThe Thead component which is the table header component.
HeaderColThe Th component which is the table header cell component.
BodyThe Tbody component which is the table body component.
RowThe Tr component which is the table row component.
CellThe Td component which is the table cell component.
FooterThe Tfoot component which is the table footer component.
TriggerThe TableTrigger component which is the optional table header col trigger component.