DataTable

DataTable is a 2-dimensional data structure where each row is an item, and each column is a data point about the item.

Page navigation navigation

React
readyReviewed for a11y

React examples

Default

Repositories

RepositoryTypeUpdatedDependabotCode scanning
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025
codeql-ci-nightliesPublicMar 21, 2025Alerts
dependabot-updatesPublicMar 20, 2025
tsx-create-react-appPublicMar 14, 2025
bootstrapPublicFeb 21, 2025Alerts
docker-templatesPublicDec 27, 2024Alerts

With custom column widths

Column sizing guidelines

Repositories

grow w/ 200px maxgrowCollapse w/ 100px minauto200pxundefined (defaults to grow)
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025
codeql-ci-nightliesPublicMar 21, 2025Alerts
dependabot-updatesPublicMar 20, 2025
tsx-create-react-appPublicMar 14, 2025
bootstrapPublicFeb 21, 2025Alerts
docker-templatesPublicDec 27, 2024Alerts

Columns text alignment

  • Left (default): Follows natural reading direction in right-to-left writing systems.
  • Right-aligned columns are used for numbers and other data that is best represented right-aligned.

In this example, there is a "Pull requests" column that is right-aligned to make it easier to visually scan and compare the numbers.

Repositories

RepositoryPull requestsTypeUpdated
codeql-dca-worker12InternalMar 21, 2025
aegir34PublicMar 21, 2025
strapi8PublicMar 21, 2025
codeql-ci-nightlies1PublicMar 21, 2025
dependabot-updates57PublicMar 20, 2025
tsx-create-react-app35PublicMar 14, 2025
bootstrap42PublicFeb 21, 2025
docker-templates3PublicDec 27, 2024

Table cell density

  • Condensed: Maximizes data visibility in a small area.
  • Normal (default): Balances data display with whitespace for clarity.
  • Spacious: Enhances readability for dense or complex content.

This example uses 'spacious' table cell padding.

Repositories

RepositoryTypeUpdatedDependabotCode scanning
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025
codeql-ci-nightliesPublicMar 21, 2025Alerts
dependabot-updatesPublicMar 20, 2025
tsx-create-react-appPublicMar 14, 2025
bootstrapPublicFeb 21, 2025Alerts
docker-templatesPublicDec 27, 2024Alerts

Sort rows by column data

If a table is sortable, one column must be sorted by default. Clicking a sorted column toggles between ascending and descending; unsorted columns sort in ascending order on first click.

In this example, the rows are sortable by "Repository" and "Updated" column data.

Repositories

TypeDependabotCode scanning
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025
codeql-ci-nightliesPublicMar 21, 2025Alerts
dependabot-updatesPublicMar 20, 2025
tsx-create-react-appPublicMar 14, 2025
bootstrapPublicFeb 21, 2025Alerts
docker-templatesPublicDec 27, 2024Alerts

With title and subtitle

Table header guidelines

Repositories

A subtitle could appear here to give extra context to the data.

RepositoryTypeUpdatedDependabotCode scanning
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025
codeql-ci-nightliesPublicMar 21, 2025Alerts
dependabot-updatesPublicMar 20, 2025
tsx-create-react-appPublicMar 14, 2025
bootstrapPublicFeb 21, 2025Alerts
docker-templatesPublicDec 27, 2024Alerts

With table action

Table header guidelines

Repositories

A subtitle could appear here to give extra context to the data.

RepositoryTypeUpdatedDependabotCode scanning
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025
codeql-ci-nightliesPublicMar 21, 2025Alerts
dependabot-updatesPublicMar 20, 2025
tsx-create-react-appPublicMar 14, 2025
bootstrapPublicFeb 21, 2025Alerts
docker-templatesPublicDec 27, 2024Alerts

With single row action

Actions that affect the item represented in the row are placed in the last column, and they don't require a visible column header.

Repositories

RepositoryTypeUpdatedDependabotCode scanning
Actions
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025
codeql-ci-nightliesPublicMar 21, 2025Alerts
dependabot-updatesPublicMar 20, 2025
tsx-create-react-appPublicMar 14, 2025
bootstrapPublicFeb 21, 2025Alerts
docker-templatesPublicDec 27, 2024Alerts

With multiple row actions

If you have multiple actions for a row, start by pulling them into a dropdown menu.

If one of the actions is heavily used, pull it out for easier access. Do not pull out more than 1 action.

Row actions in a dropdown

RepositoryTypeUpdatedDependabotCode scanning
Actions
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025

Row actions inline

RepositoryTypeUpdatedDependabotCode scanning
Actions
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025

Row actions overflowing

RepositoryTypeUpdatedDependabotCode scanning
Actions
codeql-dca-workerInternalMar 21, 2025AlertsReport secrets
aegirPublicMar 21, 2025AlertsReport secrets
strapiPublicMar 21, 2025

With paginated rows

The pagination footer shows the user where they are in relation to the total number of rows and provides controls for navigating all rows.

Guidelines on when to paginate rows

Repositories

RepositoryTypeUpdatedDependabotCode scanning
Repository 1InternalMar 21, 2025
Repository 2PublicMar 20, 2025
Repository 3PublicMar 19, 2025
Repository 4InternalMar 18, 2025
Repository 5PublicMar 17, 2025
Repository 6PublicMar 16, 2025
Repository 7InternalMar 15, 2025
Repository 8PublicMar 14, 2025
Repository 9PublicMar 13, 2025
Repository 10InternalMar 12, 2025

In a loading state

DataTables use "skeleton" loading states to indicate loading content.

Table loading state guidance

Repositories

RepositoryTypeUpdatedDependabotCode scanning
Loading
Loading
Loading
Loading
Loading

More code examples

The previous examples are a curated subset of the full capabilities of the DataTable component. For more examples, see the DataTable Storybook stories.

Props

DataTable

NameRequiredDescription
aria-describedby
string
Provide an id to an element which uniquely describes this table
aria-labelledby
string
Provide an id to an element which uniquely labels this table
data
Array<Data>
Provide a collection of the rows which will be rendered inside of the table
columns
Array<Column<Data>>
Provide the columns for the table and the fields in `data` to which they correspond
cellPadding
'condensed' | 'normal' | 'spacious'
Specify the amount of space that should be available around the contents of a cell
aria-describedby
string
Provide an id to an element which uniquely describes this table
aria-labelledby
string
Provide an id to an element which uniquely labels this table
initialSortColumn
string | number
Provide the id or field of the column by which the table is sorted. When using this `prop`, the input data must be sorted by this column in ascending order
initialSortDirection
'ASC' | 'DESC'
Provide the sort direction that the table should be sorted by on the currently sorted column

Table

NameRequiredDescription
aria-describedby
string
Provide an id to an element which uniquely describes this table
aria-labelledby
string
Provide an id to an element which uniquely labels this table
children
React.ReactNode
cellPadding
'condensed' | 'normal' | 'spacious'
Specify the amount of space that should be available around the contents of a cell

Table.Head

NameRequiredDescription
children
React.ReactNode

Table.Actions

NameRequiredDescription
children
React.ReactNode

Table.Body

NameRequiredDescription
children
React.ReactNode

Table.Row

NameRequiredDescription
children
React.ReactNode

Table.Header

NameRequiredDescription
align
'end' | 'start'
The horizontal alignment of the cell's content
children
React.ReactNode

Table.Cell

NameRequiredDescription
align
'end' | 'start'
The horizontal alignment of the cell's content
children
React.ReactNode
scope
'row'
Provide the scope for a table cell, useful for defining a row header using `scope="row"`

Table.CellPlaceholder

NameRequiredDescription

Table.Container

NameRequiredDescription
children
React.ReactNode

Table.Divider

NameRequiredDescription

Table.Title

NameRequiredDescription
children
React.ReactNode
id
Required
string
Provide a unique id for the table subtitle. This should be used along with `aria-labelledby` on `DataTable`

Table.Subtitle

NameRequiredDescription
children
React.ReactNode
id
Required
string
Provide a unique id for the table subtitle. This should be used along with `aria-describedby` on `DataTable`

Table.Skeleton

NameRequiredDescription
cellPadding
'condensed' | 'normal' | 'spacious'
Specify the amount of space that should be available around the contents of a cell
columns
Required
Array<Column<Data>>
rows
number
Optionally specify the number of rows which should be included in the skeleton state of the component

Table.Pagination

NameRequiredDescription
aria-label
Required
string
Defines a string value that labels the current element. Provide a label for the navigation landmark rendered by this component @see aria-labelledby.
defaultPageIndex
string
Provide an optional index to specify the default selected page
id
string
Optionally provide an `id` that is placed on the navigation landmark rendered by this component
onChange
({ pageIndex }: { pageIndex: number }) => void
Optionally provide a handler that is called whenever the pagination state is updated
pageSize
number
Optionally specify the number of items within a page
totalCount
Required
number
Specify the total number of items within the collection
showPages
boolean | { narrow?: boolean; regular?: boolean; wide?: boolean; }
Whether to show the page numbers

Table.ErrorDialog

NameRequiredDescription
children
Required
React.ReactNode
The content of the dialog. This is usually a message explaining the error.
title
string
The title of the dialog. This is usually a short description of the error.
onRetry
() => void
Event handler called when the user clicks the retry button.
onDismiss
() => void
Event handler called when the dialog is dismissed.

Table.SortHeader

NameRequiredDescription
direction
Required
'ASC' | 'DESC' | 'NONE'
Specify the sort direction for the TableHeader
onToggleSort
Required
() => void
Provide a handler that is called when the sortable TableHeader is interacted with via a click or keyboard interaction
align
'end' | 'start'
The horizontal alignment of the cell's content

Column options

NameRequiredDescription
align
'start' | 'end'
The horizontal alignment of the column's content
field
ObjectPaths<Data>
Optionally provide a field to render for this column. This may be the key of the object or a string that accesses nested objects through `.`. For example: `field: a.b.c` Alternatively, you may provide a `renderCell` for this column to render the field in a row
header
Required
string | (() => React.ReactNode)
Provide the name of the column. This will be rendered as a table header within the table itself
maxWidth
React.CSSProperties['maxWidth']
The maximum width the column can grow to
minWidth
React.CSSProperties['minWidth']
The minimum width the column can grow to
renderCell
(data: Data) => React.ReactNode
Provide a custom component or render prop to render the data for this column in a row
rowHeader
boolean
Specify if the value of this column for a row should be treated as a row header
sortBy
boolean | 'alphanumeric' | 'basic' | 'datetime' | (a: Data, b: Data) => number
Specify if the table should sort by this column and, if applicable, a specific sort strategy or custom sort strategy
width
'grow' | 'growCollapse' | 'auto' | React.CSSProperties['width']
Controls the width of the column. - 'grow': Stretch to fill available space, and min width is the width of the widest cell in the column - 'growCollapse': Stretch to fill available space or shrink to fit in the available space. Allows the column to shrink smaller than the cell content's width. - 'auto': The column is the width of it’s widest cell. Not intended for use with columns who’s content length varies a lot because a layout shift will occur when the content changes - explicit width: Will be exactly that width and will not grow or shrink to fill the parent