MYDS Logo

    MYDS

    Beta

    Table

    Organizes information into rows and columns for easy readability. It accommodates various data types, including text, numbers, codes, call-to-action and links, enabling efficient presentation and comparison.

    Audit log
    TimestampActivityAction Taken
    2021-09-01 12:00:00 Login attempt successful Ali
    2021-09-01 12:01:32 Page visited: /company-a/inventory Ali
    2021-09-01 12:02:03 New inventory item added: MacBook Pro Ali
    2021-09-01 12:03:45

    Inventory: MacBook Pro stock count updated: 100 units

    Ali

    Usage

    import {
      Table,
      TableBody,
      TableCaption,
      TableCell,
      TableFooter,
      TableHead,
      TableHeader,
      TableRow,
    } from "@govtechmy/myds-react/table";
    export default () => (
      <Table>
        <TableHeader>
          <TableRow>
            <TableHead />
          </TableRow>
        </TableHeader>
        <TableBody>
          <TableRow>
            <TableCell />
          </TableRow>
        </TableBody>
        <TableCaption />
      </Table>
    );

    Examples

    Basic Table

    You can use the Table component to create a basic table with headers, rows, and cells. Conventional table, th, td applies, so you can define colSpan, rowSpan, scope and other native attributes.

    Audit log
    TimestampActivityAction Taken
    2021-09-01 12:00:00 Login attempt successful Ali
    2021-09-01 12:01:32 Page visited: /company-a/inventory Ali
    2021-09-01 12:02:03 New inventory item added: MacBook Pro Ali
    2021-09-01 12:03:45

    Inventory: MacBook Pro stock count updated: 100 units

    Ali

    Row Span and Col Span

    You can use the rowSpan and colSpan attributes to merge cells in a row or column.

    Tax Assessment Year 2023
    CategoryChargeable IncomeCalculation (RM)RateTax
    A0 - 5,000On the First 5,0000RM 0
    B5,000 - 20,000On the First 5,0001%RM 0
    Next 15,000RM 150
    C20,001 - 35,000On the First 20,0003%RM 150
    Next 15,000RM 450

    You can add a footer to the table using the TableFooter component.

    Tax Assessment Year 2023
    CategoryChargeable IncomeCalculation (RM)RateTax
    A0 - 5,000On the First 5,0000RM 0
    B5,000 - 20,000On the First 5,0001%RM 0
    Next 15,000RM 150
    C20,001 - 35,000On the First 20,0003%RM 150
    Next 15,000RM 450
    Total TaxRM 600

    Skeleton Loading

    You can use the TableSkeleton component to create a skeleton loading state for the table.

    Audit log
    TimestampActivityAction Taken

    Empty Table

    Use the TableEmpty component to show the empty state.

    Audit log
    TimestampActivityAction Taken
    No data available

    Props

    TableHead

    PropTypeDefault
    rowSpan
    boolean
    false
    colSpan
    boolean
    false
    scope
    col | row | colgroup | rowgroup
    -

    TableCell

    PropTypeDefault
    rowSpan
    boolean
    false
    colSpan
    boolean
    false
    scope
    col | row | colgroup | rowgroup
    -

    On this page