Tables

The table element represents tabular data — that is, the information presented in a two-dimensional table comprised of rows and columns of cells containing data.

Ayub SalasDesignerCarroll GroupMembersalas_a
Agnes ShermanDeveloperAppleAdminshermanagnes
Jemma CummingsSenior Designer20goto10MemberjemmaC
Jimi CardenasCopywriterWind-UIOwnercardenasji
Mateusz TuckerProject ManagerTailwinduiMembermt

Variations

Simple Table

NameTitleCompanyRoleUsername
Ayub SalasDesignerCarroll GroupMembersalas_a
Agnes ShermanDeveloperAppleAdminshermanagnes
Jemma CummingsSenior Designer20goto10MemberjemmaC
Jimi CardenasCopywriterWind-UIOwnercardenasji
Mateusz TuckerProject ManagerTailwinduiMembermt
copydone

Responsive Table

Resize your browser window to the table on small screens.

Ayub SalasDesignerCarroll GroupMembersalas_a
Agnes ShermanDeveloperAppleAdminshermanagnes
Jemma CummingsSenior Designer20goto10MemberjemmaC
Jimi CardenasCopywriterWind-UIOwnercardenasji
Mateusz TuckerProject ManagerTailwinduiMembermt
copydone

Simple Table with Footer

NoProduct NameColorCategoryPrice
1Apple WatchWhiteWearables$299
2Macbook pro 16"SilverLaptops$2999
3Macbook pro 13"Space GrayLaptops$1999
Total$5297
copydone

Striped Table

NameTitleCompanyRoleUsername
Ayub SalasDesignerCarroll GroupMembersalas_a
Agnes ShermanDeveloperAppleAdminshermanagnes
Jemma CummingsSenior Designer20goto10MemberjemmaC
Jimi CardenasCopywriterWind-UIOwnercardenasji
Mateusz TuckerProject ManagerTailwinduiMembermt
copydone

Table with Hover State

NameTitleCompanyRoleUsername
Ayub SalasDesignerCarroll GroupMembersalas_a
Agnes ShermanDeveloperAppleAdminshermanagnes
Jemma CummingsSenior Designer20goto10MemberjemmaC
Jimi CardenasCopywriterWind-UIOwnercardenasji
Mateusz TuckerProject ManagerTailwinduiMembermt
copydone

Borderless Table

NameTitleCompanyRoleUsername
Ayub SalasDesignerCarroll GroupMembersalas_a
Agnes ShermanDeveloperAppleAdminshermanagnes
Jemma CummingsSenior Designer20goto10MemberjemmaC
Jimi CardenasCopywriterWind-UIOwnercardenasji
Mateusz TuckerProject ManagerTailwinduiMembermt
copydone

Underline Table

NameTitleCompanyRoleUsername
Ayub SalasDesignerCarroll GroupMembersalas_a
Agnes ShermanDeveloperAppleAdminshermanagnes
Jemma CummingsSenior Designer20goto10MemberjemmaC
Jimi CardenasCopywriterWind-UIOwnercardenasji
Mateusz TuckerProject ManagerTailwinduiMembermt
copydone

Compact Table

NameTitleCompanyRoleUsername
Ayub SalasDesignerCarroll GroupMembersalas_a
Agnes ShermanDeveloperAppleAdminshermanagnes
Jemma CummingsSenior Designer20goto10MemberjemmaC
Jimi CardenasCopywriterWind-UIOwnercardenasji
Mateusz TuckerProject ManagerTailwinduiMembermt
copydone

Usage

Data tables display information in a grid-like format of rows and columns. They organize information in a way that’s easy to scan so that users can look for patterns and develop insights from data.

Data tables can contain:

  • Interactive components (such as chips, buttons, or menus)
  • Non-interactive elements (such as badges)
  • Tools to query and manipulate data

Specs

A table consists of the following elements

  • <table> : Defines the table
  • <tbody> : Groups the body content in a table
  • <tr> : Defines rows in a table
  • <th> : Defines a header cell in a table
  • <td> : Defines a cell in a table
  • <tfoot> : Groups the footer content in a table

Tables come in 2 sizes:

  • Normal: rows have 3rem height (48px) and 1.5rem (24px) horizontal padding.Compact: rows have 2.5rem height (40px) and 1rem (16px) horizontal padding.

Wrap a table in a <div className="w-full overflow-x-auto"> to make it scroll so that users can view its data on small screens or use the responsive table instead.

Accessibility notes

  • Tables with one header and simple data are fairly accessible out of the box and may not need additional accessibility updates. Always use the simplest table configuration possible.
  • When your tables get more complex, use the <th> element to identify the header cells by adding a scope attribute. For header rows use <th scope="row">. For header columns use <th scope="col">
  • Add the optional <caption> element before the table content to give users more information on the table contents.