OverviewInstallationMigrating to 1.0Themes and layersKanok designCustomizingIconsForms and validationFrameworksUsing with AIButtonText inputText areaNumber inputSearchSelectDropdownComboboxMulti-selectCheckboxRadio buttonToggleDate pickerTime pickerSliderFile uploaderModalSide panelTearsheetNotificationToastTooltipDefinition tooltipPopoverToggletipMenuData tableStructured listPaginationContained listTree viewTabsBreadcrumbLinkPagination navContent switcherAccordionProgress indicatorUI shellTagTileCardProduct cardCode snippetCopy buttonUser avatarTruncated textListLoadingInline loadingProgress barSkeletonBadge indicatorStatus indicatorGridHeadingLayerAction setPage headerBig numberEdit in placeIntroductionText inputText areaNumber inputSearchSelectDropdownComboboxMulti-selectCheckboxRadio buttonToggleDate pickerTime pickerSliderFile uploaderTabsPagination navContent switcherTooltipDefinition tooltipPopoverMenuAccordionProgress indicatorUI shellModalSide panelTearsheetNotificationToastData tableStructured listPaginationTree viewCode snippetCopy buttonTruncated textLoadingTagCardProduct cardEdit in place
Data table
A data table shows rows of records in columns (Carbon DataTable). The web component follows Carbon web components (cds-table): you write the table as elements — <ui-table-head> with the header cells, <ui-table-body> with rows of cells — and it sorts, searches, selects, expands and pages the rows it holds. Beyond Carbon it can hide and pin columns, export CSV, edit cells in place and resize columns. The React + Tailwind DataTable is driven by data instead: you give it headers and rows.
headers and rows are the same data in every version: the HTML writes them out as elements, the React examples below map them with headerCells and cells(row) from above, and React + Tailwind takes them as props.
Installation
npmshadcn · Web componentshadcn · React + TailwindManualnpminstall@purpurabog/uinpxshadcn@4add@kanok-ui/tablenpxshadcn@4add@kanok-ui/tw-data-table# Web component# 1. Install the dependenciesnpminstalllit@^3.3.0# 2. Copy each file's "content" from# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/table.json# to its target:# components/ui/primitives/table/defs.ts# components/ui/primitives/table/table-batch-actions.ts# components/ui/primitives/table/table-body.ts# components/ui/primitives/table/table-cell.ts# components/ui/primitives/table/table-column-resize.ts# components/ui/primitives/table/table-column-settings.ts# components/ui/primitives/table/table-column.styles.ts# components/ui/primitives/table/table-csv-export.ts# components/ui/primitives/table/table-expanded-row.ts# components/ui/primitives/table/table-grid.ts# components/ui/primitives/table/table-head.ts# components/ui/primitives/table/table-header-cell.ts# components/ui/primitives/table/table-header-description.ts# components/ui/primitives/table/table-header-row.ts# components/ui/primitives/table/table-header-title.ts# components/ui/primitives/table/table-row.ts# components/ui/primitives/table/table-skeleton.ts# components/ui/primitives/table/table-toolbar-action.styles.ts# components/ui/primitives/table/table-toolbar-content.ts# components/ui/primitives/table/table-toolbar-search.ts# components/ui/primitives/table/table-toolbar.ts# components/ui/primitives/table/table.styles.ts# components/ui/primitives/table/table.ts# 3. Do the same for the items it needs (registry/<name>.json):# button, checkbox, core-column-resize, core-csv, core-grid, core-table, pagination, popover, radio, search, shared-element, shared-events, shared-field, shared-localize, shared-skeleton, tooltip, tokens# React + Tailwind# 1. Install the dependenciesnpminstall@purpurabog/ui@^2.3.0# 2. Copy each file's "content" from# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tw-data-table.json# to its target:# components/ui/react-tw/data-table.tsx# components/ui/react-tw/data-table-pins.ts# components/ui/react-tw/data-table.styles.ts# 3. Do the same for the items it needs (registry/<name>.json):# core-grid, core-table, tw-checkbox, tw-data-table-columns, tw-data-table-csv, tw-data-table-grid, tw-data-table-parts, tw-data-table-resize, tw-data-table-skeleton, tw-dom, tw-i18n, tw-pagination, tw-refs, tw-theme, tw-utils
npm gives you every component from the package. shadcn copies the source into your app instead: a copy pinned to this version that you can change. The shadcn commands need the @kanok-ui registry in your components.json once, see Installation.
@purpurabog/ui/table defines every ui-table* element. <ui-table> holds a <ui-table-head> with one <ui-table-header-row> of <ui-table-header-cell>s and a <ui-table-body> with <ui-table-row>s of <ui-table-cell>s; a cell's column is its place in the row. The title, description and toolbar go in the table's title, description and toolbar slots. The table works on the rows it finds: add, remove or reorder rows and it follows. In React + Tailwind each header is { key, header } and each row needs a stable id.
Custom cells
A cell shows whatever you put in it: a formatted number, a link, a tag. Sorting reads a cell's sort-value when it has one (give an amount shown as "1,250,000" its plain number) and CSV export its csv-value; both fall back to the cell's text. The search reads the text.
React + Tailwind renders cells with renderCell(row, header), which returns React nodes, and align: 'end' on a header puts that column's cells at the end; sorting and search use the raw values.
Sorting
is-sortable on the table gives every header a sort button; is-sortable on single headers makes only those sortable (the table's attribute sets every header). A click steps the header's sort-direction through its sort-cycle (default none → ascending → descending → none); the other headers go back to none and the table moves its rows into that order. Numbers sort by value, text by locale (default: the page's lang), and none restores the order the rows came in. A header with sort-direction in the markup sorts the rows on load. The header fires a cancelable ui-table-header-cell-sort with { oldSortDirection, sortDirection } before the rows move, and the table fires ui-table-sorted with { sortedHeader } after.
The table sorts by moving its rows in the DOM. Rows a framework renders (React, Vue, Angular) belong to the framework, so there call preventDefault() on ui-table-header-cell-sort, sort the data yourself (or on the server), render the rows in that order and set the header's sort-direction (sortDirection), as the React tab does. Replace the comparison by assigning customSortRow(lhs, rhs, collator) on the table. React + Tailwind takes defaultSortKey / defaultSortDirection and sortRow(a, b, context); with manualSorting it keeps rows in your order and only shows the sort.
Sizes and zebra stripes
size sets the row height: xs 24px, sm 32px, md 40px, lg 48px (the default), xl 64px. use-zebra-styles shades every other row. use-static-width makes the table as wide as its content instead of its container.
The toolbar follows the table's size (24px for xs, 32px for sm, 48px otherwise) and sizes the batch bar's buttons to it. In React + Tailwind, use size="sm" buttons in the toolbar and batch bar of xs and sm tables.
Selection and batch actions
is-selectable adds a checkbox to every row and a select-all box to the header row. A row with disabled can't be chosen; selected on a row chooses it. A <ui-table-batch-actions> in the toolbar holds your buttons: while rows are chosen it covers the toolbar with the count and Cancel. The table fires ui-table-row-selected with { selectedRow, selectedRows } and, after select-all or Cancel, ui-table-row-all-selected with { selectedRows }; selectedRows on the table holds the chosen rows. React + Tailwind takes batchActions, selectedIds and onSelectionChange.
ContractsSelect rows to act on themDownloadArchiveContractCounterpartyStatusService agreementAcme Co., Ltd.SignedNDAGlobexDraftLease renewalInitechIn reviewBoard resolutionVandelayArchived
Select-all follows Carbon: when any row is chosen, it releases them all; otherwise it chooses every enabled row the search shows. Before a row changes, the row fires a cancelable ui-table-row-change-selection (the header row ui-table-change-selection-all). For your own styles, chosen rows have selected, and so has the header row while any row is chosen.
Pick one row
radio makes the selection a single choice with a radio on every row, for example to pick a template. Tab stops on the chosen row, and the arrow keys move and choose. There is no batch bar.
Pick a templateTemplateTypeUpdatedStandard NDAConfidentiality2026-06-01Office leaseProperty2026-03-15Master servicesServices2025-11-20
Put a <ui-table-toolbar slot="toolbar"> on the table with a <ui-table-toolbar-content> for the controls: a <ui-table-toolbar-search>, an overflow menu, a primary button. The search stays a magnifier until pressed (Carbon's expandable search); persistent keeps it open. Typing leaves out the rows whose shown cells (and expanded row) don't contain the text, and the table fires ui-table-filtered with { unfilteredRows }. In React + Tailwind, searchable adds the search and the toolbar prop takes the other controls.
filterRows(rowText, searchString) on the table replaces the test: return true to leave the row out (Carbon's way). To search on the server, set filterRows to () => false and listen for input on the search, whose value is the text. label and placeholder on the search replace its "Filter table". React + Tailwind has its own filterRows(row, text, headers) (true keeps the row), filterText, manualFiltering, and tells screen readers "3 of 12 rows" once typing pauses.
Expandable rows
expandable on the table: a row followed by a <ui-table-expanded-row> gets a chevron that opens that full-width row of detail under it. batch-expansion adds a chevron to the header row that opens or closes every row, and expanded on a row opens it. The row fires a cancelable ui-table-row-expando-beingtoggled, then ui-table-row-expando-toggled with { expanded }.
ContractsContractCounterpartyStatusService agreementAcme Co., Ltd.SignedOwner: Kanya S. · Ends on 2027-09-30NDAGlobexDraftOwner: Anan P. · Ends on 2028-10-01Lease renewalInitechIn reviewOwner: Malee K. · Ends on 2029-01-31
HTMLReactReact + Tailwind<ui-tableexpandablebatch-expansion>
<ui-table-header-titleslot="title">Contracts</ui-table-header-title>
<ui-table-head>
<ui-table-header-row>
<ui-table-header-cell>Contract</ui-table-header-cell>
<ui-table-header-cell>Counterparty</ui-table-header-cell>
<ui-table-header-cell>Status</ui-table-header-cell>
</ui-table-header-row>
</ui-table-head>
<ui-table-body>
<ui-table-row><ui-table-cell>Service agreement</ui-table-cell><ui-table-cell>Acme Co., Ltd.</ui-table-cell><ui-table-cell>Signed</ui-table-cell></ui-table-row>
<ui-table-expanded-row>Owner: Kanya S. · Ends on 2027-09-30</ui-table-expanded-row>
<ui-table-rowexpanded><ui-table-cell>NDA</ui-table-cell><ui-table-cell>Globex</ui-table-cell><ui-table-cell>Draft</ui-table-cell></ui-table-row>
<ui-table-expanded-row>Owner: Anan P. · Ends on 2028-10-01</ui-table-expanded-row>
<ui-table-row><ui-table-cell>Lease renewal</ui-table-cell><ui-table-cell>Initech</ui-table-cell><ui-table-cell>In review</ui-table-cell></ui-table-row>
<ui-table-expanded-row>Owner: Malee K. · Ends on 2029-01-31</ui-table-expanded-row>
</ui-table-body>
</ui-table><UiTableexpandablebatchExpansion>
<UiTableHeaderTitleslot="title">Contracts</UiTableHeaderTitle>
<UiTableHead>
<UiTableHeaderRow>{headerCells}</UiTableHeaderRow>
</UiTableHead>
<UiTableBody>
{rows.map((row) => (
<Fragmentkey={row.id}>
<UiTableRowexpanded={row.id ==='2'}>{cells(row)}</UiTableRow>
<UiTableExpandedRow>Owner: {row.owner} · Ends on {row.ends}</UiTableExpandedRow>
</Fragment>
))}
</UiTableBody>
</UiTable><DataTableheading="Contracts"expandAllheaders={headers}
rows={rows}
defaultExpandedIds={['2']}
renderExpandedRow={(row) => <pclassName="m-0">Owner: {String(row.owner)} · Ends on {String(row.ends)}</p>}
/>
Pages
page-size adds a pagination bar under the table that shows that many of the rows the sort and search leave. page and page-sizes set the page and the choices, and ui-table-page-change fires with { page, pageSize }. Select-all then takes the page, and the batch bar offers "Select all (N)" for every row the search shows. Carbon has no paging on the table itself; it puts a Pagination under it.
To page on the server, render one page of rows, put your own <ui-pagination> under the table, and sort and search on the server (cancel ui-table-header-cell-sort; filterRows that keeps every row, and the search's input). On <ui-table-batch-actions>, total-rows-count offers "Select all (N)" for rows the table doesn't hold (ui-table-batch-actions-select-all-clicked fires; choose them yourself), and setting selected-rows-count in your ui-table-row-selected listener counts a selection kept across pages. React + Tailwind does the same with manualSorting, manualFiltering, totalSelected, totalCount and onSelectAll.
Show and hide columns
A <ui-table-column-settings> in the toolbar content adds a Columns button with a checkbox list of the columns. A header with hideable="false" always shows, and one with column-hidden starts hidden; Reset goes back to the columns hidden in the markup. column names a column (default: its place, "0", "1" …). The table fires ui-table-columns-change with { hiddenColumns, column, hidden }; save hiddenColumns and restore it with column-hidden on the headers or setColumnHidden(column, hidden) on the table. Hidden columns leave the search and the CSV export too.
sticky-header keeps the header row in view while the body scrolls in a box up to --ui-table-max-height tall (300px, as Carbon). For wide tables, pinned="start" on the first header keeps that column (and the chevron and checkbox columns before it) in view while the rest scrolls sideways, and pinned="end" on the last header keeps row actions at the end. Pinning starts at 672px of window width.
Contracts20 rows: scroll down, then sidewaysContractCounterpartyOwnerDepartmentUpdatedAction
Change the box's height with CSS: ui-table { --ui-table-max-height: 480px; }. React + Tailwind's DataTable reads --ui-data-table-max-height.
Export CSV
A <ui-table-csv-export> in the toolbar content adds an Export CSV button: it downloads the columns shown and the rows the search shows (sorted, every page) as a CSV file for Excel, named after its file-name or the table's title. It fires a cancelable ui-table-csv-export first with { csv, rows, fileName }. A cell writes its csv-value, else its text. toCsv({ scope }) and downloadCsv({ scope, fileName }) on the table export 'shown', 'selected' or 'all' rows from your own buttons. This demo shows the CSV instead of downloading it.
The file is UTF-8 with a byte order mark so Excel reads Thai correctly; every cell is quoted, and cells that start like a formula are made safe.
Edit cells in place
Give a header editable="text", "number" or "select" (with options, a list of { value, label } as a property or JSON in the attribute) and its cells can be edited: the table becomes a grid with one Tab stop, where the arrow keys move between cells. Enter, F2, a double click or typing opens the editor; Enter saves, Escape cancels, Tab saves and edits the next editable cell. A header's validate(value, cell) returns a message to keep the editor open. Saving fires a cancelable ui-table-cell-edit from the cell with { row, cell, column, value, previous }, then writes the value into the cell.
ContractsFocus a cell and press Enter, or double-click itNameAmount (THB)StatusOwnerOffice lease 2026250000In reviewAnanyaNDA – Acme0SignedBoonsriSoftware licence48000DraftChai
Left alone, the table writes the saved value into the cell (its text, a select column's label). Rows a framework renders belong to it, so there call preventDefault() on ui-table-cell-edit and update your data, as the React tab does; to refuse an edit, cancel it and keep the data. React + Tailwind hands you the new rows in onCellEdit: set them, or keep yours to refuse the edit.
Resize columns
resizable on the table puts a handle on the end edge of every column header, and resizable on single headers only on those: drag it, or Tab to it and use the arrow keys (Shift for 16px steps). width, min-width (default 50) and max-width in px on a header bound it. Each finished resize fires ui-table-column-resize with { column, width } from the header; columnWidths on the table holds every width. Save them and set width on the headers to restore them.
ContractsDrag a header's end edge; Amount is fixedNameStatusOwnerAmount (THB)Office lease 2026In reviewAnanya250,000NDA – AcmeSignedBoonsri0Software licenceDraftChai48,000
With no rows the table says "No data" under the headers; put your own message in the empty slot (emptyText in React + Tailwind). While a search finds nothing it says "No results found" (no-results slot, noResultsText). loading keeps the toolbar and headers and shows skeleton rows (loading-rows, default the rows shown) while the data reloads. Before the first data arrives, show <ui-table-skeleton> in the table's place.
The skeleton is hidden from screen readers: put aria-busy and a status message on the region around it. It takes headers (a property: the column names) to show real column names, zebra, show-header="false" and show-toolbar="false". React + Tailwind's DataTableSkeleton takes headers, size, zebra, hideHeader and hideToolbar.
Keyboard
Key
Does
Tab
Moves through the toolbar, the sort buttons, the checkboxes and the controls in cells; a radio table and an editable grid are one Tab stop each
Space
Toggles a checkbox; picks the focused radio row
Up / Down
In a radio table, move to the previous / next row and choose it
Arrow keys, Home / End, Ctrl + Home / End
In an editable grid, move between cells
Enter, F2
In an editable grid, edit the cell (or press the control in it)
Escape
Cancels an edit; clears the search
Accessibility
The table has the roles of a table (table, rowgroup, row, columnheader, cell; grid once a column is editable), with aria-sort on sorted columns. Name it with aria-label on <ui-table>: as in Carbon, the title isn't tied to it. Each row's checkbox, radio and chevron is named with the row's first cell ("Select row, Service agreement").
A table that scrolls (sticky-header, or wider than its box) takes focus so keyboard users can scroll it, named by its aria-label or title.
While loading, the table is aria-busy and a status says "Loading data". The batch bar's count is a status, so the new count is read when rows are chosen. React + Tailwind's DataTable also says "Sorted by Contract, ascending" after a sort and "3 of 12 rows" when typing in the search pauses.
An editable grid follows the WAI-ARIA grid pattern: cells that can't be edited are aria-readonly, and editable cells say "Press Enter to edit".
Whether the search leaves a row out: true hides it (Carbon filterRows; default: its text doesn't contain the search).
columns
UiTableHeaderCell[]
(read-only) The column headers, in order (the column settings list them).
hiddenColumns
string[]
(read-only) The keys of the hidden columns.
contentWidth
(read-only) Width of the horizontal scroll box (a resize stops a column there).
selectedRows
UiTableRow[]
(read-only) The chosen rows.
columnsChanged
(read-only) Columns were shown or hidden since the markup (Reset has something to do).
columnWidths
Record<string, number>
(read-only) The widths given or resized, by column.
csvFileName
(read-only) The file name a CSV download takes by default: the title's text.
Methods
Method
Description
customSortRow(lhs, rhs, collator)
Compares two cells' sort values (Carbon customSortRow) for ascending order: numbers by value, text with collator. Replace it on the element to sort another way.
isColumnLocked(column)
Whether column can't be hidden or shown now: not hideable, or the last one shown.
setColumnHidden(column, hidden)
Shows or hides a column (and its cells); false when it can't change (not hideable, or the last one shown).
resetColumns()
Back to the columns hidden in the markup.
freezeColumns()
The first resize freezes the automatic layout: every shown column keeps its width, a filler cell takes the rest of the row (none in a static-width table, which ends at its columns).
csvRows(scope)
The rows CSV takes: those the search shows (every page, in their order), the chosen ones, or all.
toCsv({ scope = 'shown' })
The columns shown and the rows of scope as CSV (a cell writes its csv-value, else its text).
downloadCsv({ scope = 'shown', fileName })
Downloads toCsv({ scope }) as fileName (default: the title, else "table"; .csv is added).
focus(options)
Focuses the table's first stop: the scroll box when it scrolls, else select-all, a sort button, the grid's Tab stop, or the first row's checkbox, radio or chevron.
Events
Event
React
Description
ui-table-columns-change
onUiTableColumnsChange
detail: { hiddenColumns, column, hidden } after a column was shown or hidden (column is '' after Reset)
ui-table-row-all-selected
onUiTableRowAllSelected
detail: { selectedRows } after select-all or Cancel
ui-table-sorted
onUiTableSorted
detail: { sortedHeader } after the rows were sorted by a header click
ui-table-row-selected
onUiTableRowSelected
detail: { selectedRow, selectedRows } after the user chose or released a row
ui-table-filtered
onUiTableFiltered
detail: { unfilteredRows } after the search changed which rows show
ui-table-page-change
onUiTablePageChange
detail: { page, pageSize } after the built-in pagination changed (page-size)
ui-table-cell-edit
onUiTableCellEdit
from the cell, cancelable; detail: { row, cell, column, value, previous } before an edited value is written into the cell (preventDefault() to write it yourself)
Slots
Slot
Description
(default)
<ui-table-head> and <ui-table-body>
title
A <ui-table-header-title>
description
A <ui-table-header-description>
toolbar
A <ui-table-toolbar>
empty
Shown when there are no rows (default: "No data")
no-results
Shown when the search leaves no rows (default: "No results found. Try a different search.")
CSS parts
Part
Description
header
The title / description block
content
The horizontal scroll container
table
The box laid out as a table
empty
The message under the headers when there are no rows
pagination
The built-in <ui-pagination> (page-size)
CSS custom properties
Custom property
Default
Description
--ui-table-max-height
Height of the scrolling box with sticky-header (default 300px)
--ui-table-row-height
Row height of the default size, lg (default 48px; Kanok: 40px)
--ui-table-border
/ --ui-table-radius / --ui-table-overflow - A frame around the table (default none, 0, visible; Kanok: none, 12px, clip)
--ui-table-background
Fill of the table: its title, toolbar and rows (default transparent, rows --ui-surface-1; Kanok: the cards' fill)
--ui-table-header-rule
box-shadow under the header cells (default none; Kanok: a hairline)
<ui-table-head> · React UiTableHead
Slots
Slot
Description
(default)
A <ui-table-header-row>
<ui-table-header-row> · React UiTableHeaderRow
Attributes
Attribute
Property
Type
Default
Description
selected
selected
boolean
false
Chosen (Carbon selected); the table keeps the header's select-all and the batch actions in step.
disabled
disabled
boolean
false
Can't be chosen.
radio
radio
boolean
false
A single-choice radio instead of a checkbox (the table's radio sets it).
hide-checkbox
hideCheckbox
boolean
false
No checkbox in the selection cell (the header row of a radio table).
selection-name
selectionName
string
''
Shows the selection cell: the checkbox's name (the table's is-selectable sets one).
selection-value
selectionValue
string
''
The checkbox's value.
selection-label
selectionLabel
string
''
The checkbox's accessible name; default "Select row" with the row's first cell.
expandable
expandable
boolean
false
Has a <ui-table-expanded-row> after it (the table's expandable sets it).
expanded
expanded
boolean
false
Its expanded row is open.
batch-expansion
batchExpansion
boolean
false
The header row's chevron opens and closes every row (the table's batch-expansion sets it).
filtered
filtered
boolean
false
Left out by the table's search.
highlighted
highlighted
boolean
false
Hovered with its expanded row (the two tint together).
paged-out
pagedOut
boolean
false
On another page of the table's pagination (the table sets it).
Properties
Property
Type
Description
expandColumn
boolean
The table has an expand column: every row gets the cell, expandable ones the chevron.
indeterminate
boolean
The header's select-all is partly checked (some rows chosen); the table sets it.
tabStop
boolean
The radio of a radio table that takes Tab (the chosen row, else the first); the table sets it.
pinStart
boolean
The first column is pinned: the chevron and checkbox cells stick too (the table sets it).
filler
boolean
A filler cell after the cells takes the rest of the row once the columns are resized (the table sets it).
grid
boolean
The table is a grid (an editable column): grid cells, the body's cells and controls out of the Tab order (the table sets it).
Methods
Method
Description
toggleExpanded(expanded)
Opens or closes, unless the cancelable ui-table-row-expando-beingtoggled is canceled.
gridCells()
The cells the grid's arrow keys move through: the chevron and checkbox cells, then the shown author cells.
focusSelection()
Focuses this row's selection control (a radio the arrow keys moved to).
Events
Event
React
Description
ui-table-change-selection-all
onUiTableChangeSelectionAll
cancelable; detail: { selected } before every row is chosen or released
ui-table-row-expando-beingtoggled
none (use a ref)
ui-table-row-expando-toggled
none (use a ref)
Slots
Slot
Description
(default)
The <ui-table-header-cell>s
CSS parts
Part
Description
expand-cell
The cell of the expand chevron
expand-button
The chevron button
selection-cell
The cell of the checkbox or radio
<ui-table-header-cell> · React UiTableHeaderCell
Attributes
Attribute
Property
Type
Default
Description
is-sortable
isSortable
boolean
false
Sortable on its own (the table's is-sortable sets every header).
sort-active
sortActive
boolean
false
The column the rows are sorted by (set with the direction).
sort-cycle
sortCycle
TableSortCycle | undefined
The states each click steps through.
sort-direction
sortDirection
TableSortDirection | undefined
Sorted ascending, descending or not; a sortable header without one starts at none.
column
column
string
''
The column's name in events and the column settings (default: its place, "0", "1" …).
column-hidden
columnHidden
boolean
false
Hidden with its cells (the column settings set it; set it in the markup to start hidden).
hideable
hideable
boolean
true
Can be hidden from the column settings (hideable="false" keeps it shown).
pinned
pinned
'start' | 'end' | undefined
Stays in view while the table scrolls sideways: start on the first header, end on the last.
resizable
resizable
boolean
false
A resize handle on its end edge (the table's resizable sets every header).
width
width
number | undefined
The column's width in px (a resize sets it).
min-width
minWidth
number | undefined
The narrowest a resize makes it (default 50).
max-width
maxWidth
number | undefined
The widest a resize makes it (default: the table's width).
editable
editable
TableCellEditor | undefined
Its cells can be edited in place, with this editor (no Carbon counterpart; the table becomes a grid).
options
options
TableEditOption[]
[]
A select column's choices: the value saved and the label shown (JSON in the attribute).
Checks an edited value before it's saved: a message keeps the editor open and shows it.
labelText
(read-only) The label as text (the button's title, the screen reader hint, the column settings).
columnKey
(read-only) The column's key: column, else its place among the headers.
Events
Event
React
Description
ui-table-header-cell-sort
onUiTableHeaderCellSort
cancelable; detail: { oldSortDirection, sortDirection } before the column sorts (preventDefault() keeps the rows and this header as they are: sort the data yourself and set sort-direction)
Slots
Slot
Description
(default)
The header's label
CSS parts
Part
Description
content
The box inside the header that holds its padding
sort-button
The button of a sortable header
label-text
The label
sort-icon
The sort arrow
resizer
The resize handle (an invisible range input over the end edge)
CSS custom properties
Custom property
Default
Description
--ui-table-header-background
Fill of the header (default --ui-layer-accent; Kanok: the table's fill)
--ui-table-header-ink
Text colour of the header (default --ui-ink; Kanok: secondary text)
--ui-table-sort-hover
/ --ui-table-sorted-background / --ui-table-sorted-icon - A sortable header: hover fill, the sorted column's fill and arrow (default layer-selected-hover, icon-primary; Kanok: the header fill, an --ui-icon-interactive arrow)
<ui-table-body> · React UiTableBody
Attributes
Attribute
Property
Type
Default
Description
use-zebra-styles
useZebraStyles
boolean
false
Stripe every second row (the table passes its use-zebra-styles).
Methods
Method
Description
updateZebra()
Marks the rows even / odd in document order (Carbon _updateZebra), counting only the rows shown (search, page).
Events
Event
React
Description
ui-table-body-content-change
onUiTableBodyContentChange
its rows were added, removed or reordered (the table listens)
Slots
Slot
Description
(default)
The <ui-table-row>s
<ui-table-row> · React UiTableRow
Attributes
Attribute
Property
Type
Default
Description
even
even
boolean
false
A striped row (set by the body with use-zebra-styles).
odd
odd
boolean
false
An unstriped row of a zebra table (set by the body).
selected
selected
boolean
false
Chosen (Carbon selected); the table keeps the header's select-all and the batch actions in step.
disabled
disabled
boolean
false
Can't be chosen.
radio
radio
boolean
false
A single-choice radio instead of a checkbox (the table's radio sets it).
hide-checkbox
hideCheckbox
boolean
false
No checkbox in the selection cell (the header row of a radio table).
selection-name
selectionName
string
''
Shows the selection cell: the checkbox's name (the table's is-selectable sets one).
selection-value
selectionValue
string
''
The checkbox's value.
selection-label
selectionLabel
string
''
The checkbox's accessible name; default "Select row" with the row's first cell.
expandable
expandable
boolean
false
Has a <ui-table-expanded-row> after it (the table's expandable sets it).
expanded
expanded
boolean
false
Its expanded row is open.
batch-expansion
batchExpansion
boolean
false
The header row's chevron opens and closes every row (the table's batch-expansion sets it).
filtered
filtered
boolean
false
Left out by the table's search.
highlighted
highlighted
boolean
false
Hovered with its expanded row (the two tint together).
paged-out
pagedOut
boolean
false
On another page of the table's pagination (the table sets it).
Properties
Property
Type
Description
expandColumn
boolean
The table has an expand column: every row gets the cell, expandable ones the chevron.
indeterminate
boolean
The header's select-all is partly checked (some rows chosen); the table sets it.
tabStop
boolean
The radio of a radio table that takes Tab (the chosen row, else the first); the table sets it.
pinStart
boolean
The first column is pinned: the chevron and checkbox cells stick too (the table sets it).
filler
boolean
A filler cell after the cells takes the rest of the row once the columns are resized (the table sets it).
grid
boolean
The table is a grid (an editable column): grid cells, the body's cells and controls out of the Tab order (the table sets it).
Methods
Method
Description
toggleExpanded(expanded)
Opens or closes, unless the cancelable ui-table-row-expando-beingtoggled is canceled.
gridCells()
The cells the grid's arrow keys move through: the chevron and checkbox cells, then the shown author cells.
focusSelection()
Focuses this row's selection control (a radio the arrow keys moved to).
Events
Event
React
Description
ui-table-row-change-selection
onUiTableRowChangeSelection
cancelable; detail: { selected } before the row is chosen or released
ui-table-row-expando-beingtoggled
onUiTableRowExpandoBeingtoggled
cancelable; detail: { expanded } before the row opens or closes
ui-table-row-expando-toggled
onUiTableRowExpandoToggled
detail: { expanded } after the row opened or closed
Slots
Slot
Description
(default)
The row's <ui-table-cell>s
CSS parts
Part
Description
expand-cell
The cell of the expand chevron
expand-button
The chevron button
selection-cell
The cell of the checkbox or radio
CSS custom properties
Custom property
Default
Description
--ui-table-row-selected
Fill of a chosen row (default --ui-layer-accent; Kanok: --ui-highlight)
--ui-table-row-thread
background-image of a chosen row's first cell, for a mark on its start edge (default none; Kanok: a 3px --ui-border-interactive mark)
--ui-icon-control-radius
Corners of its small icon buttons, their hover fill and ring (default 0; Kanok: round)
<ui-table-cell> · React UiTableCell
Attributes
Attribute
Property
Type
Default
Description
column-hidden
columnHidden
boolean
false
Its column is hidden (the table follows the header's column-hidden).
pinned
pinned
'start' | 'end' | undefined
Its column is pinned (the table follows the header's pinned).
editable
editable
TableCellEditor | undefined
Its column's editor (the table follows the header's editable).
editing
editing
boolean
false
The editor is open (the table sets it).
Properties
Property
Type
Description
draft
string
The editor's text while editing (the table sets where it starts).
editorLabel
string
The editor's name for screen readers: the column and the row (the table sets it).
editorOptions
TableEditOption[]
A select editor's choices (the header's options).
editorError
string
The header's validate message for the value in the editor.
editorValue
(read-only) What the editor holds now.
Methods
Method
Description
focusEditor(select)
Focuses the open editor; select selects a text editor's text (else the caret goes to the end).
Slots
Slot
Description
(default)
The cell's content
CSS parts
Part
Description
content
The box inside the cell that holds its padding
edit-icon
The pencil of an editable cell
editor
The input or select while editing
error
The validate message under the editor
CSS custom properties
Custom property
Default
Description
--ui-table-cell-ink
Text colour of a row at rest (default --ui-ink-muted; Kanok: --ui-ink)
How many rows are chosen (the table sets it; set it yourself for a selection kept across pages).
total-rows-count
totalRowsCount
number
0
Every row there is (server paging): above the count, "Select all (N)" shows.
size
size
'xs' | 'sm' | 'lg'
'lg'
The table's size, normalized to xs / sm / lg (the table sets it): sizes the action buttons.
Properties
Property
Type
Description
formatSelectedItemsCount
(options: { count: number }) => string | undefined
The count text (Carbon formatSelectedItemsCount); default: the translation.
Events
Event
React
Description
ui-table-batch-actions-cancel-clicked
onUiTableBatchActionsCancelClicked
Cancel was clicked (the table releases every row)
ui-table-batch-actions-select-all-clicked
onUiTableBatchActionsSelectAllClicked
"Select all (N)" was clicked
Slots
Slot
Description
(default)
The actions (<ui-button>s; the bar sizes them to the toolbar)
cancel-button-content
Cancel's text (default: the translation)
select-all-button-content
"Select all (N)"'s text
CSS parts
Part
Description
batch-summary
The selected-count text
select-all-button
"Select all (N)"
cancel-button
Cancel
CSS custom properties
Custom property
Default
Description
--ui-batch-background
/ --ui-batch-ink / --ui-batch-divider - The bar's fill, text and the rule before Cancel (default Carbon's brand bar: background-brand, text-on-color)
--ui-batch-button
/ --ui-batch-button-ink / --ui-batch-button-hover / --ui-batch-button-active / --ui-batch-focus - Its buttons and their focus ring (default the primary button's colours, a layer-coloured ring)