• Docs
  • Blog
    • 0.24.0

    • Switch to dark mode
    Get Started
    Components
    Styling
    Theming

    Concepts

    OverviewCompositionTesting

    Layout

    Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

    Components

    AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

    Utilities

    Feature FlagsForLocal StoragePortalShowsplitPropsTheme

    Table

    The Table component is a controlled component that can be used to display tabular data.

    • npm
    • source
    • recipe
    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.

    Note

    The sticky prop removes the border from the table so you can provide it on the scrollable container for a better design experience.

    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 or the css prop 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.

    Note

    Although the Table API is similar to the TableParts, it returns abstractions of the primitives. The TableParts return the primitives only.

    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.

    Note

    It is best to only use the TableParts if you are building a custom solution. Importing Object based components will ship every property it includes into your bundle, regardless if you use it or not.

    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.

    On this page

    • Edit this page on Github
    Cerberus Design System | Docs