27.0.0-preview.2 (most recent)27.0.0-preview.1BlazorReactWeb

Data table

A data table shows read-only rows and columns, so readers can compare values and screen readers can browse them. Choose whether a phone sees a table that scrolls sideways or rows restacked as labeled blocks; sorting needs no wiring beyond marking a column sortable. The tables below show both variants at different densities.

SeedMood
CobaltCalm
VermilionBold
DishPriceHeat
Laksa$11Hot
Soba$9Mild
TeamPoints
Otters42
Herons37
TaskOwner
LoginAda
DocsGrace
DrinkPrice
Latte$4
Cortado$4
Mocha$6
TrackTime
Kite3:12
TrackTime
Lantern2:48

Reference docs⁠

OverviewExamplesAPIStylingAccessibility

Choosing a way to show a collection⁠

Three components show many items at once. Each suits a different job:

  • List: a column of items to scan and act on, such as contacts or settings.
  • Data table: read-only rows and columns to compare, such as an invoice or a price table.
  • Data grid: many rows the reader sorts, selects, and moves through by keyboard, such as an order list of thousands.

One job belongs elsewhere. Splitting a long collection into pages is a paginator, used alongside any of these.

Choosing a variant⁠

Two variants set how much a data table stands out from the page, from most to least:

  • Surface: a table that needs its own ground, such as a list in a panel of another color, on the lowest surface container color.
  • Standard: the default, with no fill, for a table that sits directly on the page or inside a card, such as an invoice list, and takes that container's color.

Built in⁠

  • A column marked sortable in columns sorts when its header is activated, and a screen reader announces the new order.
  • stack restacks each row as a block with every value beside its column title, so a narrow screen needs no sideways scrolling.
  • A long cell wraps, so every word stays readable: the row grows rather than cutting the text. truncate-cells cuts it off with an ellipsis instead, and the full text appears when a pointer rests on the cell.
  • virtualize keeps a table of thousands of rows light.
  • Markup you already have works: a table written inside the element becomes a data table.
  • templateFields puts your own content in a cell, such as a link or a status label, through a child with a cell: slot name.

Using data tables well⁠

  • Give a numeric column the number or currency type, so its values sit at the end of the cell, and leave text columns at the start.
  • Give a currency column its currency code, such as "currency": "EUR". The table's language, the lang it inherits, decides how a price is written, not which currency it is in, and a column with no code shows plain numbers.
  • Keep column titles short, and move any explanation to the caption.
  • Put paging controls in a footer below the table, with a rows-per-page choice and a position readout such as 1–10 of 100, and slice the data yourself when the page changes.
  • Choose a data grid when rows need selecting, since a data table has no selection and no checkbox column.
  • Set stack to auto for a table people open on a phone, and leave it at the default for a table whose columns must stay aligned.

These rules follow Material 3 Expressive's guidance for data tables, on material.io.

Variants⁠

variant sets how much the table stands out; Choosing a variant says when to use each. Omit it and the table takes the variant from your style configuration, which is standard unless you have changed it.

Caption position⁠

The default slot holds the caption, which also serves as the table's name. caption-position places it before or after the rows; omit it and the table takes the position from your style configuration, which is leading unless you have changed it. With no caption, name the table with grid-label.

Density⁠

density sets how tightly rows are spaced, from 0 (the roomiest) to 4 (the tightest), five values in all. Omit it and the table takes the density from your style configuration, which is standard unless you have changed it.

Stack⁠

stack decides how a table fits a narrow width. never, the default, keeps rows as rows. always draws every row as a block with each value beside its column title, and auto does so only while the table is too narrow to show as rows. It goes by width, not by text: a cell that wraps does not stack the table, but a space narrower than the longest word in each column does. Each table below is held to 280 pixels.

Columns and rows⁠

items holds the rows, and columns describes the columns. Without columns, the table builds them from the first row's keys. Mark a column sortable and its header becomes a button; activating it cycles through ascending, descending, and unsorted. Sorting is set per column: the table itself has no sortable attribute. Set unique-identifier to the name of a field that identifies each row.

Each framework writes a column in its own way:

  • Web: an object, such as { field: "amount", title: "Amount", type: "currency", currency: "USD", sortable: true }.
  • React: the same object, in an array declared as ColumnDefinition[], a type you import from @materia-technologies-inc/chameleon-components-react. Without that type, TypeScript widens "currency" to string and rejects the array. Declare the row type with type, not interface, because a row must fit GridItem, and an interface does not.
  • Blazor: ColumnDefinition is a record, and its constructor takes the field. Write new("Amount") { Title = "Amount", Type = TableColumnKind.Currency, Currency = "USD", Sortable = true }. The form new() { Field = "Amount" } does not compile, and Type takes a TableColumnKind member, not text.

In Blazor, rows reach the browser under their C# property names, exactly as written. A row type record Invoice(string Id, string Customer, decimal Amount) takes new("Customer") and UniqueIdentifier="Id"; a lowercase "id" matches nothing. Razor works out TItem from Items="@invoices". Write it yourself, such as <CbDataTable TItem="Invoice" ...>, when the table has no Items.

Each sort fires sort-change. Its detail carries column, the sorted column's field, and direction, which is "asc", "desc" or "none". In Blazor, the OnSortChange handler takes SortChangeEventArgs and reads args.Column and args.Direction, a SortChangeDirection member such as SortChangeDirection.Asc. Blazor event arguments carry these fields directly and have no Detail.

Lines and stripes⁠

striped, show-column-dividers, and borderless change how the table separates its content. Borderless removes the outer frame and keeps the dividers between rows and cells. Each switch below sets one of them.

Wrapping text⁠

By default a cell wraps text that does not fit: rows grow to fit, and the table scrolls sideways when its content is wider than its space. truncate-cells cuts the text off with an ellipsis instead, which keeps every row one line tall; the full text shows only to a pointer, so use it where the table reads without it. The switch below turns truncation on for a table held to 360 pixels.

Cell content⁠

templateFields lists the fields whose cells show content you supply rather than the value. Add a child with slot="cell:{rowKey}:{field}" for each cell, where rowKey is the row's value in the unique-identifier field. The table then needs that identifier.

Large data sets⁠

virtualize draws only the rows in view, so give the table a CSS height to scroll within. overscan-count sets how many extra rows load beyond the visible area; keep it small. For rows that live on a server, assign itemsProvider from code: the table asks it for rows, and a table without virtualize asks once for all of them.

The provider receives a request with the first row's index and a row count, and returns those rows with the total count. In Blazor it is a method such as Task<GridItemsProviderResult<Shipment>> LoadAsync(GridRequest request) that returns new GridItemsProviderResult<Shipment>(rows, total). Razor cannot work out TItem from a method, so write it: <CbDataTable TItem="Shipment" ItemsProvider="@LoadAsync" ...>.

Written table⁠

A <table> written inside the element is its source, so crawlers and readers without script still see the rows. Header cells take options such as data-cw-field and data-cw-sortable. In Blazor, a table with written rows has no Items to infer from, so write TItem="object" on it.

Properties⁠

PropertyAttributeTypeDescription
borderlessborderlessbooleandefault falseRemoves the table's outer frame. The header's underline stays, drawn in the row divider's color and width, as do the row and cell dividers. See Lines and stripes.
captionPositioncaption-positionleading, trailingCaptionPositionCaptionPosition.Leading, .Trailingdefault CaptionPosition.Leading, from the style configurationThe caption's position in relation to the component. See Caption position.
columnsColumnDefinition[]default []Column definitions. If not provided, columns will be auto-generated from data (if possible). See Columns and rows.
densitydensity0, 1, 2, 3, 4DensityDensity.Standard, .Dense1, .Dense2, .Dense3, .Dense4default Density.Standard, from the style configurationHow tightly rows are spaced, from 0, the roomiest, to 4, the tightest. See Density.
gridLabelgrid-labelstringThe name a screen reader announces for the component. See Caption position.
itemsTItem[]default []Data source as an array of objects. Use this for client-side data. See Columns and rows.
itemsProviderGridItemsProvider<TItem>Async function to provide data. Use this for server-side operations (filtering, sorting, paging). Ignored while items has rows. See Large data sets.
overscanCountoverscan-countnumberdefault 3How many rows beyond the visible ones are fetched ahead of scrolling. Keep it small to avoid over-fetching from the server. See Large data sets.
showColumnDividersshow-column-dividersbooleandefault falseShows vertical dividers between columns, which helps tell columns apart when there are many. See Lines and stripes.
stackstacknever, always, autoTableStackTableStack.Never, .Always, .Autodefault TableStack.NeverHow the table fits a narrow width. always draws each row as a block, with every value beside its column's title; auto does so only while the table is too narrow, measured with its rows as rows: the width it has is less than the table needs with every column as narrow as it can be. That is a width test, not an overflow test. Text that wraps does not stack the table; a table stacks when the space is narrower than its columns' longest unbreakable words and their padding, a phone-width table in practice.Has no effect while virtualize is set: a virtualized table draws its rows as rows. See Stack.
stripedstripedbooleandefault falseShades alternate rows. See Lines and stripes.
templateFieldsstring[]default []The fields whose cells show content the page supplies, through a child with slot="cell:{rowKey}:{field}", rather than their value. Every cell of such a field shows its slot, so the content can arrive after the row is drawn; rows-change names the rows drawn. {rowKey} is the row's value in the uniqueIdentifier field, which these fields need.A written <table> needs no list: any written cell with such a child shows it in place of its copy. See Cell content.
touchTargettouch-targetnone, overflow, wrapperTouchTargetTouchTarget.None, .Overflow, .Wrapperdefault TouchTarget.Overflow, from the style configurationThe touch target of the sort buttons in the header: none leaves the buttons their visible area, and overflow adds a touch target as large as the header cell and never past it, so a header shorter than 48 pixels gives no press to the first row. wrapper is read as overflow: a sort button fills its header cell, so an added wrapper would only make the header taller, and the table never does that. The configuration supplies the default.
truncateCellstruncate-cellsbooleandefault falseCells cut their text off with an ellipsis rather than wrapping it, and show the full text as the cell's hover title. By default cells wrap: rows grow to fit, the row height is a minimum, columns size to their content and the table scrolls sideways when its content is wider than its space. A cut-off cell's text can be reached by pointer alone, so set this where rows must keep one height and the text is not needed to read the table.A virtualized table wraps as well, and its rows grow to fit; its columns keep their widths, so the header stays over its column. See Wrapping text.
uniqueIdentifierunique-identifierstringThe name of a field whose value identifies a row. Optional, except when templateFields is set. Without it, the table cannot restore keyboard focus to the same row after a sort, filter or page change, so it drops focus. See Columns and rows, Cell content.
variantvariantstandard, surfaceTableVariantTableVariant.Standard, .Surfacedefault TableVariant.Standard, from the style configurationThe component's color scheme. surface uses the lowest surface container color, and standard no fill, taking the color of whatever the table sits on. Unset, it comes from the style configuration's defaultTableVariant, which ships as standard. See Variants.
virtualizevirtualizebooleandefault falseShows only the rows in view, for large datasets. Rows may differ in height: each is measured as it is drawn. See Large data sets.

When items and itemsProvider are both set, items wins, and a warning is logged. A written table in the content takes precedence over items, also with a warning. Without virtualize, a provider is called once for every row.

Slots⁠

SlotDescription
(default)Caption content displayed above or below the table. Not rendered while a written <table> is the source; its <caption> is shown instead.

A child with slot name cell:{rowKey}:{field} fills one cell; see templateFields. A caption replaces grid-label as the accessible name.

Events⁠

EventTypeDetailDescription
sort-changeSortChangeEventSortChangeEventDetailDispatched when the sort state changes (a sortable column header is activated). It bubbles and is composed.
rows-changeRowsChangeEventRowsChangeEventDetailDispatched when the rows drawn change, naming each drawn row's key in order, so a page can supply cell-slot content for the drawn rows alone. It bubbles and is composed.
cell-activateCellActivateEventCellActivateEventDetail<TItem>Dispatched when a control rendered by ColumnDefinition.actionLabel/actionHref is activated: by pointer or Enter, and by Space on an actionLabel button. It bubbles and is composed.

With items, a sort reorders a copy and leaves the array unchanged. With itemsProvider, the sort reaches the provider as sortDescriptors, and the provider must sort.

Props⁠

PropTypeDescription
borderlessbooleandefault falseRemoves the table's outer frame. The header's underline stays, drawn in the row divider's color and width, as do the row and cell dividers. See Lines and stripes.
captionPositionCaptionPositionTypeCaptionPosition.Leading, .Trailingdefault CaptionPosition.Leading, from the style configurationThe caption's position in relation to the component. See Caption position.
columnsColumnDefinition[]default []Column definitions. If not provided, columns will be auto-generated from data (if possible). See Columns and rows.
densityDensityTypeDensity.Standard, .Dense1, .Dense2, .Dense3, .Dense4default Density.Standard, from the style configurationHow tightly rows are spaced, from 0, the roomiest, to 4, the tightest. See Density.
gridLabelstringThe name a screen reader announces for the component. See Caption position.
itemsTItem[]default []Data source as an array of objects. Use this for client-side data. See Columns and rows.
itemsProviderGridItemsProvider<TItem>Async function to provide data. Use this for server-side operations (filtering, sorting, paging). Ignored while items has rows. See Large data sets.
overscanCountnumberdefault 3How many rows beyond the visible ones are fetched ahead of scrolling. Keep it small to avoid over-fetching from the server. See Large data sets.
showColumnDividersbooleandefault falseShows vertical dividers between columns, which helps tell columns apart when there are many. See Lines and stripes.
stackTableStackTypeTableStack.Never, .Always, .Autodefault TableStack.NeverHow the table fits a narrow width. always draws each row as a block, with every value beside its column's title; auto does so only while the table is too narrow, measured with its rows as rows: the width it has is less than the table needs with every column as narrow as it can be. That is a width test, not an overflow test. Text that wraps does not stack the table; a table stacks when the space is narrower than its columns' longest unbreakable words and their padding, a phone-width table in practice.Has no effect while virtualize is set: a virtualized table draws its rows as rows. See Stack.
stripedbooleandefault falseShades alternate rows. See Lines and stripes.
templateFieldsstring[]default []The fields whose cells show content the page supplies, through a child with slot="cell:{rowKey}:{field}", rather than their value. Every cell of such a field shows its slot, so the content can arrive after the row is drawn; rows-change names the rows drawn. {rowKey} is the row's value in the uniqueIdentifier field, which these fields need.A written <table> needs no list: any written cell with such a child shows it in place of its copy. See Cell content.
touchTargetTouchTargetTypeTouchTarget.None, .Overflow, .Wrapperdefault TouchTarget.Overflow, from the style configurationThe touch target of the sort buttons in the header: none leaves the buttons their visible area, and overflow adds a touch target as large as the header cell and never past it, so a header shorter than 48 pixels gives no press to the first row. wrapper is read as overflow: a sort button fills its header cell, so an added wrapper would only make the header taller, and the table never does that. The configuration supplies the default.
truncateCellsbooleandefault falseCells cut their text off with an ellipsis rather than wrapping it, and show the full text as the cell's hover title. By default cells wrap: rows grow to fit, the row height is a minimum, columns size to their content and the table scrolls sideways when its content is wider than its space. A cut-off cell's text can be reached by pointer alone, so set this where rows must keep one height and the text is not needed to read the table.A virtualized table wraps as well, and its rows grow to fit; its columns keep their widths, so the header stays over its column. See Wrapping text.
uniqueIdentifierstringThe name of a field whose value identifies a row. Optional, except when templateFields is set. Without it, the table cannot restore keyboard focus to the same row after a sort, filter or page change, so it drops focus. See Columns and rows, Cell content.
variantTableVariantTypeTableVariant.Standard, .Surfacedefault TableVariant.Standard, from the style configurationThe component's color scheme. surface uses the lowest surface container color, and standard no fill, taking the color of whatever the table sits on. Unset, it comes from the style configuration's defaultTableVariant, which ships as standard. See Variants.
virtualizebooleandefault falseShows only the rows in view, for large datasets. Rows may differ in height: each is measured as it is drawn. See Large data sets.

When items and itemsProvider are both set, items wins, and a warning is logged. A written table in the content takes precedence over items, also with a warning. Without virtualize, a provider is called once for every row.

Children⁠

ChildDescription
childrenCaption content displayed above or below the table. Not rendered while a written <table> is the source; its <caption> is shown instead.

A child with slot name cell:{rowKey}:{field} fills one cell; see templateFields. A caption replaces grid-label as the accessible name.

Events⁠

PropArgumentDescription
onSortChangeSortChangeEventDispatched when the sort state changes (a sortable column header is activated). It bubbles and is composed. Its detail carries column, direction, and sortDescriptors.
onRowsChangeRowsChangeEventDispatched when the rows drawn change, naming each drawn row's key in order, so a page can supply cell-slot content for the drawn rows alone. It bubbles and is composed. Its detail carries keys.
onCellActivateCellActivateEvent<TItem>Dispatched when a control rendered by ColumnDefinition.actionLabel/actionHref is activated: by pointer or Enter, and by Space on an actionLabel button. It bubbles and is composed. Its detail carries item, rowIndex, field, columnIndex, value, and originalEvent.

With items, a sort reorders a copy and leaves the array unchanged. With itemsProvider, the sort reaches the provider as sortDescriptors, and the provider must sort.

Parameters⁠

ParameterTypeDescription
Borderlessbool?default falseRemoves the table's outer frame. The header's underline stays, drawn in the row divider's color and width, as do the row and cell dividers. See Lines and stripes.
CaptionPositionCaptionPosition?CaptionPosition.Leading, .Trailingdefault CaptionPosition.Leading, from the style configurationThe caption's position in relation to the component. See Caption position.
Columnsinteractive rendering onlyIEnumerable<ColumnDefinition>?default []Column definitions. If not provided, columns will be auto-generated from data (if possible). See Columns and rows.
DensityDensity?Density.Standard, .Dense1, .Dense2, .Dense3, .Dense4default Density.Standard, from the style configurationHow tightly rows are spaced, from 0, the roomiest, to 4, the tightest. See Density.
GridLabelstring?The name a screen reader announces for the component. See Caption position.
Itemsinteractive rendering onlyIEnumerable<TItem>?default []Data source as an array of objects. Use this for client-side data. See Columns and rows.
ItemsProviderinteractive rendering onlyGridItemsProvider<TItem>?Async function to provide data. Use this for server-side operations (filtering, sorting, paging). Ignored while Items has rows. See Large data sets.
OverscanCountint?default 3How many rows beyond the visible ones are fetched ahead of scrolling. Keep it small to avoid over-fetching from the server. See Large data sets.
ShowColumnDividersbool?default falseShows vertical dividers between columns, which helps tell columns apart when there are many. See Lines and stripes.
StackTableStack?TableStack.Never, .Always, .Autodefault TableStack.NeverHow the table fits a narrow width. always draws each row as a block, with every value beside its column's title; auto does so only while the table is too narrow, measured with its rows as rows: the width it has is less than the table needs with every column as narrow as it can be. That is a width test, not an overflow test. Text that wraps does not stack the table; a table stacks when the space is narrower than its columns' longest unbreakable words and their padding, a phone-width table in practice.Has no effect while Virtualize is set: a virtualized table draws its rows as rows. See Stack.
Stripedbool?default falseShades alternate rows. See Lines and stripes.
TemplateFieldsinteractive rendering onlyIEnumerable<string>?default []The fields whose cells show content the page supplies, through a child with slot="cell:{rowKey}:{field}", rather than their value. Every cell of such a field shows its slot, so the content can arrive after the row is drawn; rows-change names the rows drawn. {rowKey} is the row's value in the UniqueIdentifier field, which these fields need.A written <table> needs no list: any written cell with such a child shows it in place of its copy. See Cell content.
TouchTargetTouchTarget?TouchTarget.None, .Overflow, .Wrapperdefault TouchTarget.Overflow, from the style configurationThe touch target of the sort buttons in the header: none leaves the buttons their visible area, and overflow adds a touch target as large as the header cell and never past it, so a header shorter than 48 pixels gives no press to the first row. wrapper is read as overflow: a sort button fills its header cell, so an added wrapper would only make the header taller, and the table never does that. The configuration supplies the default.
TruncateCellsbool?default falseCells cut their text off with an ellipsis rather than wrapping it, and show the full text as the cell's hover title. By default cells wrap: rows grow to fit, the row height is a minimum, columns size to their content and the table scrolls sideways when its content is wider than its space. A cut-off cell's text can be reached by pointer alone, so set this where rows must keep one height and the text is not needed to read the table.A virtualized table wraps as well, and its rows grow to fit; its columns keep their widths, so the header stays over its column. See Wrapping text.
UniqueIdentifierstring?The name of a field whose value identifies a row. Optional, except when TemplateFields is set. Without it, the table cannot restore keyboard focus to the same row after a sort, filter or page change, so it drops focus. See Columns and rows, Cell content.
VariantTableVariant?TableVariant.Standard, .Surfacedefault TableVariant.Standard, from the style configurationThe component's color scheme. surface uses the lowest surface container color, and standard no fill, taking the color of whatever the table sits on. Unset, it comes from the style configuration's defaultTableVariant, which ships as standard. See Variants.
Virtualizebool?default falseShows only the rows in view, for large datasets. Rows may differ in height: each is measured as it is drawn. See Large data sets.

When items and itemsProvider are both set, items wins, and a warning is logged. A written table in the content takes precedence over items, also with a warning. Without virtualize, a provider is called once for every row.

Render fragments⁠

ParameterTypeDescription
ChildContentRenderFragment?Caption content displayed above or below the table. Not rendered while a written <table> is the source; its <caption> is shown instead.

A child with slot name cell:{rowKey}:{field} fills one cell; see templateFields. A caption replaces grid-label as the accessible name.

Event callbacks⁠

ParameterTypeDescription
OnSortChangeEventCallback<SortChangeEventArgs>Dispatched when the sort state changes (a sortable column header is activated). It bubbles and is composed. The handler's argument has Column, Direction, and SortDescriptors: read args.Column; there is no Detail.
OnRowsChangeEventCallback<RowsChangeEventArgs>Dispatched when the rows drawn change, naming each drawn row's key in order, so a page can supply cell-slot content for the drawn rows alone. It bubbles and is composed. The handler's argument has Keys: read args.Keys; there is no Detail.
OnCellActivateEventCallback<CellActivateEventArgs<TItem>>Dispatched when a control rendered by ColumnDefinition.actionLabel/actionHref is activated: by pointer or Enter, and by Space on an actionLabel button. It bubbles and is composed. The handler's argument has Item, RowIndex, Field, ColumnIndex, Value, and OriginalEvent: read args.Item; there is no Detail.

With items, a sort reorders a copy and leaves the array unchanged. With itemsProvider, the sort reaches the provider as sortDescriptors, and the provider must sort.

Inputs⁠

InputTypeDescription
borderlessbooleandefault falseRemoves the table's outer frame. The header's underline stays, drawn in the row divider's color and width, as do the row and cell dividers. See Lines and stripes.
captionPositionCaptionPositionTypeCaptionPosition.Leading, .Trailingdefault CaptionPosition.Leading, from the style configurationThe caption's position in relation to the component. See Caption position.
columnsColumnDefinition[]default []Column definitions. If not provided, columns will be auto-generated from data (if possible). See Columns and rows.
densityDensityTypeDensity.Standard, .Dense1, .Dense2, .Dense3, .Dense4default Density.Standard, from the style configurationHow tightly rows are spaced, from 0, the roomiest, to 4, the tightest. See Density.
gridLabelstringThe name a screen reader announces for the component. See Caption position.
itemsTItem[]default []Data source as an array of objects. Use this for client-side data. See Columns and rows.
itemsProviderGridItemsProvider<TItem>Async function to provide data. Use this for server-side operations (filtering, sorting, paging). Ignored while items has rows. See Large data sets.
overscanCountnumberdefault 3How many rows beyond the visible ones are fetched ahead of scrolling. Keep it small to avoid over-fetching from the server. See Large data sets.
showColumnDividersbooleandefault falseShows vertical dividers between columns, which helps tell columns apart when there are many. See Lines and stripes.
stackTableStackTypeTableStack.Never, .Always, .Autodefault TableStack.NeverHow the table fits a narrow width. always draws each row as a block, with every value beside its column's title; auto does so only while the table is too narrow, measured with its rows as rows: the width it has is less than the table needs with every column as narrow as it can be. That is a width test, not an overflow test. Text that wraps does not stack the table; a table stacks when the space is narrower than its columns' longest unbreakable words and their padding, a phone-width table in practice.Has no effect while virtualize is set: a virtualized table draws its rows as rows. See Stack.
stripedbooleandefault falseShades alternate rows. See Lines and stripes.
templateFieldsstring[]default []The fields whose cells show content the page supplies, through a child with slot="cell:{rowKey}:{field}", rather than their value. Every cell of such a field shows its slot, so the content can arrive after the row is drawn; rows-change names the rows drawn. {rowKey} is the row's value in the uniqueIdentifier field, which these fields need.A written <table> needs no list: any written cell with such a child shows it in place of its copy. See Cell content.
touchTargetTouchTargetTypeTouchTarget.None, .Overflow, .Wrapperdefault TouchTarget.Overflow, from the style configurationThe touch target of the sort buttons in the header: none leaves the buttons their visible area, and overflow adds a touch target as large as the header cell and never past it, so a header shorter than 48 pixels gives no press to the first row. wrapper is read as overflow: a sort button fills its header cell, so an added wrapper would only make the header taller, and the table never does that. The configuration supplies the default.
truncateCellsbooleandefault falseCells cut their text off with an ellipsis rather than wrapping it, and show the full text as the cell's hover title. By default cells wrap: rows grow to fit, the row height is a minimum, columns size to their content and the table scrolls sideways when its content is wider than its space. A cut-off cell's text can be reached by pointer alone, so set this where rows must keep one height and the text is not needed to read the table.A virtualized table wraps as well, and its rows grow to fit; its columns keep their widths, so the header stays over its column. See Wrapping text.
uniqueIdentifierstringThe name of a field whose value identifies a row. Optional, except when templateFields is set. Without it, the table cannot restore keyboard focus to the same row after a sort, filter or page change, so it drops focus. See Columns and rows, Cell content.
variantTableVariantTypeTableVariant.Standard, .Surfacedefault TableVariant.Standard, from the style configurationThe component's color scheme. surface uses the lowest surface container color, and standard no fill, taking the color of whatever the table sits on. Unset, it comes from the style configuration's defaultTableVariant, which ships as standard. See Variants.
virtualizebooleandefault falseShows only the rows in view, for large datasets. Rows may differ in height: each is measured as it is drawn. See Large data sets.

When items and itemsProvider are both set, items wins, and a warning is logged. A written table in the content takes precedence over items, also with a warning. Without virtualize, a provider is called once for every row.

Content projection⁠

ContentDescription
content with no slotCaption content displayed above or below the table. Not rendered while a written <table> is the source; its <caption> is shown instead.

A child with slot name cell:{rowKey}:{field} fills one cell; see templateFields. A caption replaces grid-label as the accessible name.

Outputs⁠

OutputEventDescription
cwSortChangeSortChangeEventDispatched when the sort state changes (a sortable column header is activated). It bubbles and is composed. Its detail carries column, direction, and sortDescriptors.
cwRowsChangeRowsChangeEventDispatched when the rows drawn change, naming each drawn row's key in order, so a page can supply cell-slot content for the drawn rows alone. It bubbles and is composed. Its detail carries keys.
cwCellActivateCellActivateEventDispatched when a control rendered by ColumnDefinition.actionLabel/actionHref is activated: by pointer or Enter, and by Space on an actionLabel button. It bubbles and is composed. Its detail carries item, rowIndex, field, columnIndex, value, and originalEvent.

With items, a sort reorders a copy and leaves the array unchanged. With itemsProvider, the sort reaches the provider as sortDescriptors, and the provider must sort.

Props⁠

PropTypeDescription
borderlessbooleandefault falseRemoves the table's outer frame. The header's underline stays, drawn in the row divider's color and width, as do the row and cell dividers. See Lines and stripes.
captionPositionCaptionPositionTypeCaptionPosition.Leading, .Trailingdefault CaptionPosition.Leading, from the style configurationThe caption's position in relation to the component. See Caption position.
columnsColumnDefinition[]default []Column definitions. If not provided, columns will be auto-generated from data (if possible). See Columns and rows.
densityDensityTypeDensity.Standard, .Dense1, .Dense2, .Dense3, .Dense4default Density.Standard, from the style configurationHow tightly rows are spaced, from 0, the roomiest, to 4, the tightest. See Density.
gridLabelstringThe name a screen reader announces for the component. See Caption position.
itemsTItem[]default []Data source as an array of objects. Use this for client-side data. See Columns and rows.
itemsProviderGridItemsProvider<TItem>Async function to provide data. Use this for server-side operations (filtering, sorting, paging). Ignored while items has rows. See Large data sets.
overscanCountnumberdefault 3How many rows beyond the visible ones are fetched ahead of scrolling. Keep it small to avoid over-fetching from the server. See Large data sets.
showColumnDividersbooleandefault falseShows vertical dividers between columns, which helps tell columns apart when there are many. See Lines and stripes.
stackTableStackTypeTableStack.Never, .Always, .Autodefault TableStack.NeverHow the table fits a narrow width. always draws each row as a block, with every value beside its column's title; auto does so only while the table is too narrow, measured with its rows as rows: the width it has is less than the table needs with every column as narrow as it can be. That is a width test, not an overflow test. Text that wraps does not stack the table; a table stacks when the space is narrower than its columns' longest unbreakable words and their padding, a phone-width table in practice.Has no effect while virtualize is set: a virtualized table draws its rows as rows. See Stack.
stripedbooleandefault falseShades alternate rows. See Lines and stripes.
templateFieldsstring[]default []The fields whose cells show content the page supplies, through a child with slot="cell:{rowKey}:{field}", rather than their value. Every cell of such a field shows its slot, so the content can arrive after the row is drawn; rows-change names the rows drawn. {rowKey} is the row's value in the uniqueIdentifier field, which these fields need.A written <table> needs no list: any written cell with such a child shows it in place of its copy. See Cell content.
touchTargetTouchTargetTypeTouchTarget.None, .Overflow, .Wrapperdefault TouchTarget.Overflow, from the style configurationThe touch target of the sort buttons in the header: none leaves the buttons their visible area, and overflow adds a touch target as large as the header cell and never past it, so a header shorter than 48 pixels gives no press to the first row. wrapper is read as overflow: a sort button fills its header cell, so an added wrapper would only make the header taller, and the table never does that. The configuration supplies the default.
truncateCellsbooleandefault falseCells cut their text off with an ellipsis rather than wrapping it, and show the full text as the cell's hover title. By default cells wrap: rows grow to fit, the row height is a minimum, columns size to their content and the table scrolls sideways when its content is wider than its space. A cut-off cell's text can be reached by pointer alone, so set this where rows must keep one height and the text is not needed to read the table.A virtualized table wraps as well, and its rows grow to fit; its columns keep their widths, so the header stays over its column. See Wrapping text.
uniqueIdentifierstringThe name of a field whose value identifies a row. Optional, except when templateFields is set. Without it, the table cannot restore keyboard focus to the same row after a sort, filter or page change, so it drops focus. See Columns and rows, Cell content.
variantTableVariantTypeTableVariant.Standard, .Surfacedefault TableVariant.Standard, from the style configurationThe component's color scheme. surface uses the lowest surface container color, and standard no fill, taking the color of whatever the table sits on. Unset, it comes from the style configuration's defaultTableVariant, which ships as standard. See Variants.
virtualizebooleandefault falseShows only the rows in view, for large datasets. Rows may differ in height: each is measured as it is drawn. See Large data sets.

When items and itemsProvider are both set, items wins, and a warning is logged. A written table in the content takes precedence over items, also with a warning. Without virtualize, a provider is called once for every row.

Slots⁠

SlotDescription
defaultCaption content displayed above or below the table. Not rendered while a written <table> is the source; its <caption> is shown instead.

A child with slot name cell:{rowKey}:{field} fills one cell; see templateFields. A caption replaces grid-label as the accessible name.

Events⁠

EventTypeDescription
sortChangeSortChangeEventDispatched when the sort state changes (a sortable column header is activated). It bubbles and is composed. Its detail carries column, direction, and sortDescriptors.
rowsChangeRowsChangeEventDispatched when the rows drawn change, naming each drawn row's key in order, so a page can supply cell-slot content for the drawn rows alone. It bubbles and is composed. Its detail carries keys.
cellActivateCellActivateEventDispatched when a control rendered by ColumnDefinition.actionLabel/actionHref is activated: by pointer or Enter, and by Space on an actionLabel button. It bubbles and is composed. Its detail carries item, rowIndex, field, columnIndex, value, and originalEvent.

With items, a sort reorders a copy and leaves the array unchanged. With itemsProvider, the sort reaches the provider as sortDescriptors, and the provider must sort.

Props⁠

PropTypeDescription
borderlessbooleandefault falseRemoves the table's outer frame. The header's underline stays, drawn in the row divider's color and width, as do the row and cell dividers. See Lines and stripes.
captionPositionCaptionPositionTypeCaptionPosition.Leading, .Trailingdefault CaptionPosition.Leading, from the style configurationThe caption's position in relation to the component. See Caption position.
columnsColumnDefinition[]default []Column definitions. If not provided, columns will be auto-generated from data (if possible). See Columns and rows.
densityDensityTypeDensity.Standard, .Dense1, .Dense2, .Dense3, .Dense4default Density.Standard, from the style configurationHow tightly rows are spaced, from 0, the roomiest, to 4, the tightest. See Density.
gridLabelstringThe name a screen reader announces for the component. See Caption position.
itemsTItem[]default []Data source as an array of objects. Use this for client-side data. See Columns and rows.
itemsProviderGridItemsProvider<TItem>Async function to provide data. Use this for server-side operations (filtering, sorting, paging). Ignored while items has rows. See Large data sets.
overscanCountnumberdefault 3How many rows beyond the visible ones are fetched ahead of scrolling. Keep it small to avoid over-fetching from the server. See Large data sets.
showColumnDividersbooleandefault falseShows vertical dividers between columns, which helps tell columns apart when there are many. See Lines and stripes.
stackTableStackTypeTableStack.Never, .Always, .Autodefault TableStack.NeverHow the table fits a narrow width. always draws each row as a block, with every value beside its column's title; auto does so only while the table is too narrow, measured with its rows as rows: the width it has is less than the table needs with every column as narrow as it can be. That is a width test, not an overflow test. Text that wraps does not stack the table; a table stacks when the space is narrower than its columns' longest unbreakable words and their padding, a phone-width table in practice.Has no effect while virtualize is set: a virtualized table draws its rows as rows. See Stack.
stripedbooleandefault falseShades alternate rows. See Lines and stripes.
templateFieldsstring[]default []The fields whose cells show content the page supplies, through a child with slot="cell:{rowKey}:{field}", rather than their value. Every cell of such a field shows its slot, so the content can arrive after the row is drawn; rows-change names the rows drawn. {rowKey} is the row's value in the uniqueIdentifier field, which these fields need.A written <table> needs no list: any written cell with such a child shows it in place of its copy. See Cell content.
touchTargetTouchTargetTypeTouchTarget.None, .Overflow, .Wrapperdefault TouchTarget.Overflow, from the style configurationThe touch target of the sort buttons in the header: none leaves the buttons their visible area, and overflow adds a touch target as large as the header cell and never past it, so a header shorter than 48 pixels gives no press to the first row. wrapper is read as overflow: a sort button fills its header cell, so an added wrapper would only make the header taller, and the table never does that. The configuration supplies the default.
truncateCellsbooleandefault falseCells cut their text off with an ellipsis rather than wrapping it, and show the full text as the cell's hover title. By default cells wrap: rows grow to fit, the row height is a minimum, columns size to their content and the table scrolls sideways when its content is wider than its space. A cut-off cell's text can be reached by pointer alone, so set this where rows must keep one height and the text is not needed to read the table.A virtualized table wraps as well, and its rows grow to fit; its columns keep their widths, so the header stays over its column. See Wrapping text.
uniqueIdentifierstringThe name of a field whose value identifies a row. Optional, except when templateFields is set. Without it, the table cannot restore keyboard focus to the same row after a sort, filter or page change, so it drops focus. See Columns and rows, Cell content.
variantTableVariantTypeTableVariant.Standard, .Surfacedefault TableVariant.Standard, from the style configurationThe component's color scheme. surface uses the lowest surface container color, and standard no fill, taking the color of whatever the table sits on. Unset, it comes from the style configuration's defaultTableVariant, which ships as standard. See Variants.
virtualizebooleandefault falseShows only the rows in view, for large datasets. Rows may differ in height: each is measured as it is drawn. See Large data sets.

When items and itemsProvider are both set, items wins, and a warning is logged. A written table in the content takes precedence over items, also with a warning. Without virtualize, a provider is called once for every row.

Snippets⁠

SnippetDescription
childrenCaption content displayed above or below the table. Not rendered while a written <table> is the source; its <caption> is shown instead.

A child with slot name cell:{rowKey}:{field} fills one cell; see templateFields. A caption replaces grid-label as the accessible name.

Events⁠

PropTypeDescription
onSortChangeSortChangeEventDispatched when the sort state changes (a sortable column header is activated). It bubbles and is composed. Its detail carries column, direction, and sortDescriptors.
onRowsChangeRowsChangeEventDispatched when the rows drawn change, naming each drawn row's key in order, so a page can supply cell-slot content for the drawn rows alone. It bubbles and is composed. Its detail carries keys.
onCellActivateCellActivateEventDispatched when a control rendered by ColumnDefinition.actionLabel/actionHref is activated: by pointer or Enter, and by Space on an actionLabel button. It bubbles and is composed. Its detail carries item, rowIndex, field, columnIndex, value, and originalEvent.

With items, a sort reorders a copy and leaves the array unchanged. With itemsProvider, the sort reaches the provider as sortDescriptors, and the provider must sort.

Each attribute value has its own tokens; a cell shows its token's value, and selecting the cell shows the token's fallback path, with each name and value ready to copy. For example, the standard column's error-color row is --ct-table-standard-error-color, which defaults to --ct-sys-color-error.

Variant⁠

Namestandardsurface
error-color--ct-sys-color-error --ct-table-standard-error-color--ct-sys-color-error --ct-table-surface-error-color
error-container-color--ct-sys-color-error-container --ct-table-standard-error-container-color--ct-sys-color-error-container --ct-table-surface-error-container-color
header-container-colortransparent --ct-table-standard-header-container-color--ct-sys-color-surface-container-lowest --ct-table-surface-header-container-color
header-headline-color--ct-sys-color-on-surface --ct-table-standard-header-headline-color--ct-sys-color-on-surface --ct-table-surface-header-headline-color
header-hover-headline-colorsame as row-item-label-text-color --ct-table-standard-header-hover-headline-colorsame as row-item-label-text-color --ct-table-surface-header-hover-headline-color
header-hover-sorting-icon-button-colorsame as row-item-label-text-color --ct-table-standard-header-hover-sorting-icon-button-colorsame as row-item-label-text-color --ct-table-surface-header-hover-sorting-icon-button-color
on-error-container-color--ct-sys-color-on-error-container --ct-table-standard-on-error-container-color--ct-sys-color-on-error-container --ct-table-surface-on-error-container-color
outline-color--ct-sys-color-outline-variant --ct-table-standard-outline-color--ct-sys-color-outline-variant --ct-table-surface-outline-color
row-item-container-colortransparent --ct-table-standard-row-item-container-color--ct-sys-color-surface-container-lowest --ct-table-surface-row-item-container-color
row-item-hover-label-text-color--ct-sys-color-on-surface-hover --ct-table-standard-row-item-hover-label-text-color--ct-sys-color-on-surface-hover --ct-table-surface-row-item-hover-label-text-color
row-item-hover-state-layer-color--ct-sys-color-on-surface --ct-table-standard-row-item-hover-state-layer-color--ct-sys-color-on-surface --ct-table-surface-row-item-hover-state-layer-color
row-item-hover-state-layer-opacity--ct-sys-state-hover-state-layer-opacity --ct-table-standard-row-item-hover-state-layer-opacity--ct-sys-state-hover-state-layer-opacity --ct-table-surface-row-item-hover-state-layer-opacity
row-item-label-text-color--ct-sys-color-on-surface --ct-table-standard-row-item-label-text-color--ct-sys-color-on-surface --ct-table-surface-row-item-label-text-color
row-item-outline-color--ct-sys-color-outline-variant --ct-table-standard-row-item-outline-color--ct-sys-color-outline-variant --ct-table-surface-row-item-outline-color
row-item-pressed-label-text-color--ct-sys-color-on-surface-pressed --ct-table-standard-row-item-pressed-label-text-color--ct-sys-color-on-surface-pressed --ct-table-surface-row-item-pressed-label-text-color
row-item-pressed-state-layer-colorsame as row-item-hover-state-layer-color --ct-table-standard-row-item-pressed-state-layer-colorsame as row-item-hover-state-layer-color --ct-table-surface-row-item-pressed-state-layer-color
row-item-pressed-state-layer-opacity--ct-sys-state-pressed-state-layer-opacity --ct-table-standard-row-item-pressed-state-layer-opacity--ct-sys-state-pressed-state-layer-opacity --ct-table-surface-row-item-pressed-state-layer-opacity
row-item-selected-hover-label-text-color--ct-sys-color-on-surface-selected-hover --ct-table-standard-row-item-selected-hover-label-text-color--ct-sys-color-on-surface-hover --ct-table-surface-row-item-selected-hover-label-text-color
row-item-selected-hover-state-layer-color--ct-sys-color-on-surface-selected-state-layer --ct-table-standard-row-item-selected-hover-state-layer-colorsame as row-item-hover-state-layer-color --ct-table-surface-row-item-selected-hover-state-layer-color
row-item-selected-hover-state-layer-opacity--ct-sys-state-hover-state-layer-opacity --ct-table-standard-row-item-selected-hover-state-layer-opacity--ct-sys-state-hover-state-layer-opacity --ct-table-surface-row-item-selected-hover-state-layer-opacity
row-item-selected-label-text-colorsame as row-item-label-text-color --ct-table-standard-row-item-selected-label-text-colorsame as row-item-label-text-color --ct-table-surface-row-item-selected-label-text-color
row-item-selected-pressed-label-text-color--ct-sys-color-on-surface-selected-pressed --ct-table-standard-row-item-selected-pressed-label-text-color--ct-sys-color-on-surface-pressed --ct-table-surface-row-item-selected-pressed-label-text-color
row-item-selected-pressed-state-layer-color--ct-sys-color-on-surface-selected-state-layer --ct-table-standard-row-item-selected-pressed-state-layer-color--ct-sys-color-on-surface --ct-table-surface-row-item-selected-pressed-state-layer-color
row-item-selected-pressed-state-layer-opacity--ct-sys-state-pressed-state-layer-opacity --ct-table-standard-row-item-selected-pressed-state-layer-opacity--ct-sys-state-pressed-state-layer-opacity --ct-table-surface-row-item-selected-pressed-state-layer-opacity
scrollbar-color--ct-sys-color-outline-variant --ct-table-standard-scrollbar-color--ct-sys-color-outline-variant --ct-table-surface-scrollbar-color
scrollbar-thumb-color--ct-sys-color-on-surface-variant --ct-table-standard-scrollbar-thumb-color--ct-sys-color-on-surface-variant --ct-table-surface-scrollbar-thumb-color
scrollbar-thumb-hover-color--ct-sys-color-on-surface --ct-table-standard-scrollbar-thumb-hover-color--ct-sys-color-on-surface --ct-table-surface-scrollbar-thumb-hover-color

Other tokens⁠

These stay the same whatever the variant.

TokenValue
--ct-table-caption-text-color--ct-sys-color-on-surface --ct-table-caption-text-color
--ct-table-caption-text-font--ct-sys-typescale-title-medium-font --ct-table-caption-text-font
--ct-table-caption-text-line-height--ct-sys-typescale-title-medium-line-height --ct-table-caption-text-line-height
--ct-table-caption-text-size--ct-sys-typescale-title-medium-size --ct-table-caption-text-size
--ct-table-caption-text-tracking--ct-sys-typescale-title-medium-tracking --ct-table-caption-text-tracking
--ct-table-caption-text-weight--ct-sys-typescale-title-medium-weight --ct-table-caption-text-weight
--ct-table-footer-container-dense-1-height48px --ct-table-footer-container-dense-1-height
--ct-table-footer-container-dense-2-height44px --ct-table-footer-container-dense-2-height
--ct-table-footer-container-dense-3-height40px --ct-table-footer-container-dense-3-height
--ct-table-footer-container-dense-4-height36px --ct-table-footer-container-dense-4-height
--ct-table-footer-container-standard-height52px --ct-table-footer-container-standard-height
--ct-table-header-container-dense-1-height52px --ct-table-header-container-dense-1-height
--ct-table-header-container-dense-2-height48px --ct-table-header-container-dense-2-height
--ct-table-header-container-dense-3-height44px --ct-table-header-container-dense-3-height
--ct-table-header-container-dense-4-height40px --ct-table-header-container-dense-4-height
--ct-table-header-container-standard-height56px --ct-table-header-container-standard-height
--ct-table-header-headline-font--ct-sys-typescale-title-small-font --ct-table-header-headline-font
--ct-table-header-headline-size--ct-sys-typescale-title-small-size --ct-table-header-headline-size
--ct-table-header-headline-weight--ct-sys-typescale-title-small-weight --ct-table-header-headline-weight
--ct-table-header-sticky-offset0px --ct-table-header-sticky-offset
--ct-table-outline-width1px --ct-table-outline-width
--ct-table-row-item-label-text-font--ct-sys-typescale-body-medium-font --ct-table-row-item-label-text-font
--ct-table-row-item-label-text-size--ct-sys-typescale-body-medium-size --ct-table-row-item-label-text-size
--ct-table-row-item-label-text-weight--ct-sys-typescale-body-medium-weight --ct-table-row-item-label-text-weight
--ct-table-row-item-outline-width1px --ct-table-row-item-outline-width
--ct-table-row-layers-container-dense-1-height48px --ct-table-row-layers-container-dense-1-height
--ct-table-row-layers-container-dense-2-height44px --ct-table-row-layers-container-dense-2-height
--ct-table-row-layers-container-dense-3-height40px --ct-table-row-layers-container-dense-3-height
--ct-table-row-layers-container-dense-4-height36px --ct-table-row-layers-container-dense-4-height
--ct-table-row-layers-container-standard-height52px --ct-table-row-layers-container-standard-height

Names and states⁠

A screen reader announces a data table as a table with a header row. It follows the WAI-ARIA Authoring Practices: Table pattern, a static table with no cell navigation.

  • The caption is the first source of the name. Without one, grid-label names it, and a written table falls back to its own aria-label.
  • An aria-label set on the data table has no effect. Give the table a caption or grid-label.
  • A screen reader announces the row and column counts, and reads each header cell as a column header.
  • A sortable header is a button named for its column, and a screen reader announces its sort state. The sort arrow itself is not announced.
  • A sort is announced in a live region, such as "Sorted by Customer, ascending". Loads announce "Loading data", "Loaded 3 rows", and "No data to display".
  • Choose a data grid when readers must move between cells by keyboard or select rows. A data table has no cell roles.

Keyboard and focus⁠

Key Action
Tab Moves to the next control in the table, such as a sort button, a cell action, or your own content.
Shift+Tab Moves to the previous control.
Enter Activates the focused sort button or cell action.
Space Activates the focused sort button or a cell action button. A cell action link takes Enter, as any link does.

These are the keys of an ordinary button or link; the table adds no keys of its own.

  • A sort button shows a focus ring on keyboard focus.
  • Cells are not focusable. Only interactive content inside cells is in the Tab order.
  • A table that scrolls takes one Tab stop, announced as a group named by grid-label or "Scrollable table", so keyboard users can scroll it. A table that does not scroll takes no Tab stop.

Pointer and touch⁠

  • The sort arrow is always visible, so touch users can see that a header is interactive.
  • touch-target sets the touch target of the sort buttons. The default, from your style configuration, is overflow, which makes each button as large as its header cell. none leaves only the visible button, and wrapper acts as overflow, because the table never grows its header.
  • Keep controls you place in cells, such as buttons from cell content, at least 24 by 24 pixels, the minimum in WCAG 2.5.8.

Display settings⁠

  • Forced colors: row dividers stay visible and take a system color.
  • Reduced motion: the table has no animation, so the setting changes nothing.
  • Right-to-left: text columns start at the inline edge, which is the right edge in a right-to-left layout.

Standards⁠

With its defaults, a data table meets four WCAG 2.2 success criteria:

  • 1.3.1 Info and Relationships (A)
  • 2.1.1 Keyboard (A)
  • 2.4.7 Focus Visible (AA)
  • 4.1.2 Name, Role, Value (A)

Three more depend on how you use it:

  • 1.1.1 Non-text Content (A): give every image in a cell a text alternative, or an empty alt when it is decorative.
  • 2.4.6 Headings and Labels (AA): give the table a caption or grid-label that describes its content, and keep column titles short.
  • 2.5.8 Target Size (Minimum) (AA): keep every control you place in a cell at least 24 by 24 pixels.