Table

import Table, { Thead, Trow, Tcol } from 'frui/Table';
Copy

Props

NameTypeFor ElementRequiredNotes
classNamestringNoStandard HTML class names
colSpanbooleanThead, Tfoot, TcolNoHow many columns this cell will cover
noWrapbooleanThead, Tfoot, TcolNoKeeps all text in one line
rowSpanbooleanTcolNoHow many rows this cell will cover
stickyBottombooleanTfootNoAlways show on the bottom, even on overflow
stickyLeftbooleanThead, Tfoot, TcolNoAlways show on the left, even on overflow
stickyRightbooleanThead, Tfoot, TcolNoAlways show on the right, even on overflow
stickyTopbooleanTheadNoAlways show on the top, even on overflow
styleCSS ObjectAllNoStandard CSS input
wrap1booleanThead, Tfoot, TcolNoKeeps the cell size a minimum of 100px
wrap2booleanThead, Tfoot, TcolNoKeeps the cell size a minimum of 200px
wrap3booleanThead, Tfoot, TcolNoKeeps the cell size a minimum of 300px
wrap4booleanThead, Tfoot, TcolNoKeeps the cell size a minimum of 400px
wrap5booleanThead, Tfoot, TcolNoKeeps the cell size a minimum of 500px

Basic

Tables do not need: thead, and tbody elements as in the following basic example.

IDNameActiveCreatedUpdated
1John DoeYes2021-01-012021-01-01
2Jane DoeNo2021-01-012021-01-01
<Table className="w-full">
  <Thead className="bg-b3 text-left">ID</Thead>
  <Thead className="bg-b3 text-left">Name</Thead>
  <Thead className="bg-b3 text-center">Active</Thead>
  <Thead className="bg-b3 text-right">Created</Thead>
  <Thead className="bg-b3 text-right">Updated</Thead>
  <Trow>
    <Tcol className="bg-b1">1</Tcol>
    <Tcol className="bg-b1">John Doe</Tcol>
    <Tcol className="bg-b1 text-center">Yes</Tcol>
    <Tcol className="bg-b1 text-right">2021-01-01</Tcol>
    <Tcol className="bg-b1 text-right">2021-01-01</Tcol>
  </Trow>
  <Trow>
    <Tcol className="bg-b2">2</Tcol>
    <Tcol className="bg-b2">Jane Doe</Tcol>
    <Tcol className="bg-b2 text-center">No</Tcol>
    <Tcol className="bg-b2 text-right">2021-01-01</Tcol>
    <Tcol className="bg-b2 text-right">2021-01-01</Tcol>
  </Trow>
</Table>
Copy

Wrap & No Wrap

Headers and cell width can be manipulated using noWrap, wrap1, wrap2, wrap3, wrap4, and wrap5.

IDNameActiveCreatedUpdated
1Duis id ante leo. Morbi orci ex, porttitor nec turpis ac, rutrum laoreet tellus. Cras nulla justo, consectetur eget ante non, faucibus finibus velit. Phasellus mollis sapien egestas, convallis magna id, egestas eros. Donec mauris leo, cursus sit amet ullamcorper ac, pretium vitae massa. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed vitae orci felis. Etiam finibus, massa vel semper sagittis, velit nulla hendrerit justo, in ultrices lorem magna vitae quam.
Yes2021-01-012021-01-01
2Maecenas enim nibh, tincidunt lacinia molestie id, dictum vel felis. Cras laoreet laoreet arcu eu tincidunt. Aenean hendrerit mi purus, id vestibulum ligula tempus nec. Praesent sollicitudin ligula et ipsum gravida viverra. Cras pretium neque arcu, vitae mollis orci iaculis et. Nullam egestas nec sem in mollis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque lobortis leo eu enim dapibus, at tempor metus egestas. Aliquam in eros ut erat fermentum volutpat ac in magna. Curabitur a magna at sem lacinia tristique ac ut nibh. Nulla erat nulla, mollis at finibus eget, mollis eu felis.
No2021-01-012021-01-01
<Table>
  <Thead className="bg-b3 text-left">ID</Thead>
  <Thead className="bg-b3 text-left">Name</Thead>
  <Thead className="bg-b3 text-center">Active</Thead>
  <Thead className="bg-b3 text-right">Created</Thead>
  <Thead className="bg-b3 text-right">Updated</Thead>
  <Trow>
    <Tcol className="bg-b1">1</Tcol>
    <Tcol wrap3 className="bg-b1">
      Duis id ante leo. Morbi orci ex, porttitor nec 
      turpis ac, rutrum laoreet tellus. Cras nulla 
      justo, consectetur eget ante non, faucibus 
      finibus velit. Phasellus mollis sapien egestas, 
      convallis magna id, egestas eros. Donec mauris 
      leo, cursus sit amet ullamcorper ac, pretium 
      vitae massa. Orci varius natoque penatibus et 
      magnis dis parturient montes, nascetur ridiculus 
      mus. Sed vitae orci felis. Etiam finibus, massa 
      vel semper sagittis, velit nulla hendrerit justo, 
      in ultrices lorem magna vitae quam.
    </Tcol>
    <Tcol className="bg-b1 text-center">Yes</Tcol>
    <Tcol noWrap className="bg-b1 text-right">2021-01-01</Tcol>
    <Tcol noWrap className="bg-b1 text-right">2021-01-01</Tcol>
  </Trow>
  <Trow>
    <Tcol className="bg-b2">2</Tcol>
    <Tcol wrap3 className="bg-b2">
      Maecenas enim nibh, tincidunt lacinia molestie 
      id, dictum vel felis. Cras laoreet laoreet arcu 
      eu tincidunt. Aenean hendrerit mi purus, id 
      vestibulum ligula tempus nec. Praesent 
      sollicitudin ligula et ipsum gravida viverra. 
      Cras pretium neque arcu, vitae mollis orci 
      iaculis et. Nullam egestas nec sem in mollis. 
      Vestibulum ante ipsum primis in faucibus orci 
      luctus et ultrices posuere cubilia curae; 
      Pellentesque habitant morbi tristique senectus 
      et netus et malesuada fames ac turpis egestas. 
      Quisque lobortis leo eu enim dapibus, at tempor 
      metus egestas. Aliquam in eros ut erat fermentum 
      volutpat ac in magna. Curabitur a magna at sem lacinia 
      tristique ac ut nibh. Nulla erat nulla, mollis at 
      finibus eget, mollis eu felis.</Tcol>
    <Tcol className="bg-b2 text-center">No</Tcol>
    <Tcol noWrap className="bg-b2 text-right">2021-01-01</Tcol>
    <Tcol noWrap className="bg-b2 text-right">2021-01-01</Tcol>
  </Trow>
</Table>
Copy

Sticky

Headers and cells can use a combination of stickLeft, stickyTop, stickyBottom, stickyRight to make tables in the mobile view responsive.

IDFirst NameLast NameActiveCreatedUpdated
1JohnDoeYes2021-01-012021-01-02
2JaneDoeNo2021-02-032021-02-04
3JackDoeNo2021-03-052021-03-06
4JanDoeNo2021-04-072021-04-08
5JimmyDoeYes2021-05-092021-05-10
6JennyDoeNo2021-06-112021-06-12
<div className="h-64 w-72 overflow-auto">
  <Table className="w-full">
    <Thead stickyTop stickyLeft className="bg-b3 text-left">ID</Thead>
    <Thead stickyTop noWrap className="bg-b3 text-left">First Name</Thead>
    <Thead stickyTop noWrap className="bg-b3 text-left">Last Name</Thead>
    <Thead stickyTop className="bg-b3 text-center">Active</Thead>
    <Thead stickyTop className="bg-b3 text-right">Created</Thead>
    <Thead stickyTop className="bg-b3 text-right">Updated</Thead>
    <Trow>
      <Tcol stickyLeft className="bg-b1">1</Tcol>
      <Tcol className="bg-b1">John</Tcol>
      <Tcol className="bg-b1">Doe</Tcol>
      <Tcol className="bg-b1 text-center">Yes</Tcol>
      <Tcol noWrap className="bg-b1 text-right">2021-01-01</Tcol>
      <Tcol noWrap className="bg-b1 text-right">2021-01-02</Tcol>
    </Trow>
    <Trow>
      <Tcol stickyLeft className="bg-b2">2</Tcol>
      <Tcol className="bg-b2">Jane</Tcol>
      <Tcol className="bg-b2">Doe</Tcol>
      <Tcol className="bg-b2 text-center">No</Tcol>
      <Tcol noWrap className="bg-b2 text-right">2021-02-03</Tcol>
      <Tcol noWrap className="bg-b2 text-right">2021-02-04</Tcol>
    </Trow>
    <Trow>
      <Tcol stickyLeft className="bg-b1">3</Tcol>
      <Tcol className="bg-b1">Jack</Tcol>
      <Tcol className="bg-b1">Doe</Tcol>
      <Tcol className="bg-b1 text-center">No</Tcol>
      <Tcol noWrap className="bg-b1 text-right">2021-03-05</Tcol>
      <Tcol noWrap className="bg-b1 text-right">2021-03-06</Tcol>
    </Trow>
    <Trow>
      <Tcol stickyLeft className="bg-b2">4</Tcol>
      <Tcol className="bg-b2">Jan</Tcol>
      <Tcol className="bg-b2">Doe</Tcol>
      <Tcol className="bg-b2 text-center">No</Tcol>
      <Tcol noWrap className="bg-b2 text-right">2021-04-07</Tcol>
      <Tcol noWrap className="bg-b2 text-right">2021-04-08</Tcol>
    </Trow>
    <Trow>
      <Tcol stickyLeft className="bg-b1">5</Tcol>
      <Tcol className="bg-b1">Jimmy</Tcol>
      <Tcol className="bg-b1">Doe</Tcol>
      <Tcol className="bg-b1 text-center">Yes</Tcol>
      <Tcol noWrap className="bg-b1 text-right">2021-05-09</Tcol>
      <Tcol noWrap className="bg-b1 text-right">2021-05-10</Tcol>
    </Trow>
    <Trow>
      <Tcol stickyLeft className="bg-b2">6</Tcol>
      <Tcol className="bg-b2">Jenny</Tcol>
      <Tcol className="bg-b2">Doe</Tcol>
      <Tcol className="bg-b2 text-center">No</Tcol>
      <Tcol noWrap className="bg-b2 text-right">2021-06-11</Tcol>
      <Tcol noWrap className="bg-b2 text-right">2021-06-12</Tcol>
    </Trow>
  </Table>
</div>
Copy

Custom Styles

You can add your own custom class to table components or use any combination of frui-tbl-col, frui-tbl-row, frui-tbl-head, and frui-tbl-foot CSS classes.