Examples

Basic

Users
Name
Email
Role
Alice Johnson
alice@example.com
Admin
Bob Smith
bob@example.com
Editor
Carol White
carol@example.com
Viewer

Keyed Columns

Users (keyed)
Name
Email
Role
Alice Johnson
alice@example.com
Admin
Bob Smith
bob@example.com
Editor
Carol White
carol@example.com
Viewer
Users (positional twin)
Name
Email
Role
Alice Johnson
alice@example.com
Admin
Bob Smith
bob@example.com
Editor
Carol White
carol@example.com
Viewer

Keyed Columns — per-column features

Name
Department Status
Alice Johnson
Engineering
Active
Bob Smith
Design
Pending
Carol White
Inactive

Built-in Cell Renderers

Show built-in cells

Interactive Cell Renderers

Show interactive cells

Header Metadata + getSortValue

Order
Name
Amount
Status
ORD-9f3k2m8x7c1v5b9n4q6w2e
alice
₹4,938.10
Active
ORD-2
Bob
₹19,752.40
Paused
ORD-3
carol
₹1,200.00
Active

Server-mode Sort

Name Score
Gamma
30
Alpha
10
Beta
20

Sort request: none

Operational Table — Custom Cells and Data States

Record
Owner
Actions
INV-1041
Alice
Detail
INV-1042
Bob
Detail
INV-1043
Carol
Detail

Last action: none

Controlled Sort + Controlled Search

Name
Score
Alice
30
Bob
20
Carol
10

Sort: score desc · Reported: none · Term: empty

Page Ownership — External Shrink

Item
Qty
Row 01
1
Row 02
2
Row 03
3
Row 04
4
Row 05
5

Page Ownership — Server Requests

Record
Record 06
Record 07
Record 08
Record 09
Record 10

Serving page 2 × 5 · Requested: — / —

Built-in Pagination + Row Numbers

#Item
Qty
1
Item 01
0
2
Item 02
3
3
Item 03
6
4
Item 04
9
5
Item 05
12

Pagination Footer on a Single Page (showFooterOnSinglePage)

Item
Qty
Item 1
1
Item 2
2
Item 3
3

Count-Only Pagination Footer (pagination.hideControls)

Item
Qty
Item 1
1
Item 2
2
Item 3
3
Item 4
4
Item 5
5
Item 6
6

Table Follow-up API

Name
Docs Provider
Follow-up 1
Breeze
Follow-up 2
Breeze

Pagination — Page-Size Selector Hidden (pagination.hidePageSizeSelector)

Item
Qty
Item 1
1
Item 2
2

Pagination — Steppers Hidden (pagination.hideSteppers)

Item
Qty
Item 1
1
Item 2
2

Controlled Selection + Toolbar

Name Team
Alice
Engineering
Bob
Design
Carol
Marketing
Dan
Sales

Last bulk action: none

Paginated Selection (page-scoped select-all)

Member
Member 1
Member 2
Member 3
Member 4
Member 5

Selected: empty

Media Cell Renderers

Gateway Product
UPI + Card
Silk Kurta
Silk Kurta SKU-1042
NetBanking
C
Cotton Saree SKU-2088

Server-Mode Pagination

Record
Record 01
Record 02
Record 03
Record 04
Record 05

Custom Cell Rendering

Name
Department Status Score
Alice Johnson
Engineering
Active
94
Bob Smith
Design
Pending
78
Carol White
Marketing
Inactive
65
Dan Brown
Engineering
Review
88

Row Click

Product
Category
Price
MacBook Pro
Laptop
$2,499
iPhone 15
Phone
$999
AirPods Pro
Audio
$249

Sticky Header

Employee scores by department
Name
Department
Score
Status
Alice Johnson
Engineering
94
Active
Bob Smith
Design
78
Pending
Carol White
Marketing
65
Inactive
Dan Brown
Engineering
88
Review
Eve Davis
Sales
92
Active
Frank Miller
Engineering
71
Pending
Grace Lee
Marketing
85
Active
Hank Wilson
Design
69
Inactive
Ivy Chen
Sales
91
Active
Jack Taylor
Engineering
76
Review

Custom Sort Icons

City
Population
Area (km²)
Tokyo
13960000
2194
Delhi
11030000
1484
Shanghai
24870000
6341
Mumbai
12440000
603

Empty State

Name
Email
Role

No data found

Try adjusting your search or filters.

Paginator Slot

Name
Department
Role
Alice Johnson
Engineering
Staff Engineer
Bob Smith
Design
Product Designer
Carol White
Marketing
Growth Lead

Row & Cell Test IDs

Name
Score
Status
Alice Johnson
94
Active
Bob Smith
78
Pending
Carol White
65
Inactive

Checkbox Selection (multiple)

Name
Department
Role
Alice Johnson
Engineering
Staff Engineer
Bob Smith
Design
Product Designer
Carol White
Marketing
Growth Lead
Dan Brown
Engineering
Senior Engineer
Eve Davis
Sales
Account Executive

Checkbox Selection (single)

Name
Department
Role
Alice Johnson
Engineering
Staff Engineer
Bob Smith
Design
Product Designer
Carol White
Marketing
Growth Lead
Dan Brown
Engineering
Senior Engineer
Eve Davis
Sales
Account Executive

Search (client-side filtering)

Name
Department
Score
Status
Alice Johnson
Engineering
94
Active
Bob Smith
Design
78
Pending
Carol White
Marketing
65
Inactive
Dan Brown
Engineering
88
Review
Eve Davis
Sales
92
Active
Frank Miller
Engineering
71
Pending

Search (inline header trigger)

searchConfig.displayMode: 'inline' renders a compact magnifying-glass icon inside the last header cell instead of the persistent search bar above the table. Clicking it expands an input in place; it collapses back to the icon on blur once emptied.

Phone Number (4)
7740027120
9876543210
8123456789
9998887776

Search (server-side delegation via onSearchChange)

Product
Category
Price
MacBook Pro 16"
Laptops
$3,499
MacBook Air M3
Laptops
$1,299
iPhone 15 Pro
Phones
$999
iPhone 15
Phones
$799
iPad Pro 13"
Tablets
$1,099
AirPods Pro 2
Audio
$249
Apple Watch S9
Wearables
$399

Showing 7 of 7 products

Editable Cells (onCellChange pattern)

Table does not forward onCellChange internally — wire your handler directly inside the cell snippet, which runs in consumer scope.

Name
Department

Live data: [["Alice Johnson","Engineering"],["Bob Smith","Design"],["Carol White","Marketing"]]

usePortal — in-cell dropdown escapes a clipping container

With usePortal, a type: 'select' cell's dropdown (and in-cell menus) are portaled to <body> so the table's own overflow can't clip them.

Name
Tier
Row one

Mobile Record Cards (mobileCardLayout)

Resize below 640px (or open dev tools' device toolbar) to see each row become a bordered card of label/value pairs instead of a horizontally-scrolling row. Every column header still renders in the DOM as a visually-hidden <span aria-hidden="true"> label beside its value, and role="table"/"rowgroup"/"row"/"columnheader"/"cell" are restated on the native elements so the accessible structure survives the layout switch — see "Mobile Record Cards" in the Table docs for why.

Name
Department Status
Alice Johnson
Engineering
Active
Bob Smith
Design
Pending
Carol White
Inactive

Documentation

A sortable data table with clean, modern defaults. Supports column sorting (ascending/descending) for string, number, and boolean values. Features sticky headers, custom cell rendering via Svelte 5 snippets, row click interaction, customizable sort icons, a footer paginator slot, per-row/cell data-pw test ID callbacks, opt-in checkbox row selection (single and multiple mode), and a built-in search bar with client-side filtering or server-side delegation. Data is supplied either through the keyed column model (columns/rows, preferred — cells addressed by column id, with per-column sortable/testId/custom cell snippet options) or the positional model (tableHeaders/tableData, an array of arrays).

Usage

Describe columns once and address row values by column id (the keyed column model). Missing keys render as empty cells.

<script lang="ts">
  import { Table, type TableColumn, type TableRow } from '@juspay/svelte-ui-components';

  const columns: TableColumn[] = [
    { id: 'name', label: 'Name' },
    { id: 'email', label: 'Email' },
    { id: 'role', label: 'Role', sortable: false }
  ];

  const rows: TableRow[] = [
    { name: 'Alice', email: 'alice@example.com', role: 'Admin' },
    { name: 'Bob', email: 'bob@example.com', role: 'Editor' }
  ];
</script>

<Table {columns} {rows} />

Positional Model (legacy)

The original positional API remains fully supported and unchanged — pass parallel tableHeaders/tableData arrays. The keyed model is normalized internally onto the same engine, so sorting, search, selection, and snippets behave identically across both.

<Table
  tableHeaders={['Name', 'Email', 'Role']}
  tableData={[
    ['Alice', 'alice@example.com', 'Admin'],
    ['Bob', 'bob@example.com', 'Editor']
  ]}
/>

Keyed Column Options

Per-column options: sortable: false opts a single column out of sorting, testId emits a data-pw attribute on that column's header cell, and type: 'custom' with a cell snippet gives the column its own renderer receiving the keyed row:

<script lang="ts">
  const columns: TableColumn[] = [
    { id: 'name', label: 'Name' },
    { id: 'status', label: 'Status', type: 'custom', cell: statusCell }
  ];
</script>

{#snippet statusCell(row: TableRow, rowIndex: number)}
  <Pill
    text={String(row.status)}
    classes={row.status === 'Active' ? 'pill-success' : 'pill-error'}
  />
{/snippet}

The projection used internally is exported as normalizeColumns(columns, rows) so consumers can unit-test their own column/row assembly against the exact shape Table renders.

Built-in Cell Renderers

Beyond 'text' and 'custom', column.type selects a built-in renderer composed purely from library primitives. Each expects its matching cell-data shape as the row value and falls back to plain text for scalar values (so mixed columns are well-defined). All appearance is themeable via --table-cell-* / --table-trend-* / --table-link-* CSS variables.

type Cell value shape Renders
tag TableTagCellData { text, classes?, dismissible?, testId? } a single Pill — the consumer owns tone→class mapping
text-tag TableTextTagCellData { text, tag? } text with an optional trailing Pill
two-line-text TableTwoLineTextCellData { text1?, text2? } primary line over secondary line
icon-label TableIconLabelCellData { icons?, label? } leading image(s) plus a label
image-two-line-text TableImageTwoLineTextCellData { imageUrl?, text1?, text2? } thumbnail (or placeholder) plus two lines
tag-array TableTagArrayCellItem[] { text, classes? }[] a wrapping row of Pills
avatar-stack TableAvatarStackCellData { items: { id, label? }[], max? } initials chips capped at max (default 4) with a +N overflow
compare TableCompareCellData { primary?, comparison?, trendPercent?, trendLabel?, animateTrend? } value over comparison with a colored trend row (↑ green / ↓ red / label)
toggle TableToggleCellData { checked?, ariaLabel?, testId? } a Toggle; column.onToggle(rowIndex, checked) receives the new state after the flip
link TableLinkCellData { url, label?, copyable? } (or a bare url string) external link with an optional copy-to-clipboard affordance
select TableSelectCellData { options, selectedId?, placeholder?, disabled?, ariaLabel?, testId?, itemTestId? } a named Select; column.onSelect(rowIndex, selectedId, originalIndex)
input TableInputCellData { value?, placeholder?, disabled?, testId?, ariaLabel?, iconUrl?, dataType?, validationPattern?, onErrorMessage? } an Input; column.oninput(rowIndex, value, originalIndex). ariaLabel names the field for screen readers (recommended — cells have no visible label); iconUrl renders a passive leading icon
button TableButtonCellData — union: { text, iconUrl?, ariaLabel?, … } (text button) or { iconUrl, ariaLabel, … } (icon-only) a Button; column.onButtonClick(rowIndex, originalIndex). Icon-only buttons render as a bare ghost control and require ariaLabel (enforced by the type and the runtime narrowing)
action-group TableActionGroupCellData { primaryButton?, menuItems? } a primary Button plus a kebab overflow Menu; column.onPrimaryAction / column.onMenuAction
popup-menu TablePopupMenuCellData { items, ariaLabel? } a kebab-triggered row Menu; column.onMenuAction(rowIndex, itemId, originalIndex)

Icon URLs in cell data (iconUrl) are scheme-validated at narrowing time: only http:, https:, data:image/<svg+xml|png|jpeg|jpg|gif|webp>, and scheme-less (relative) URLs are accepted — anything else is dropped. A text button whose icon URL is rejected still renders (without the icon); an icon-only cell whose URL is rejected (or whose ariaLabel is missing) fails narrowing entirely, and the cell renders the raw value via the plain-text fallback ('-' for objects).

A compare cell's trendPercent defaults to plain text; set animateTrend: true on that row's cell data to roll it through AnimatedNumber instead, so a trend that updates in place (a live dashboard, a polling total) counts to its new value rather than jumping. It's per-cell rather than a column- or table-level switch, so a column can mix live rows with historical ones that shouldn't move. The up/down arrow, its colour, and the flat (trendPercent === 0) case are unaffected. The % is passed through AnimatedNumber with the number rather than left beside it, so it forms part of the odometer's accessible name — a unit outside a role="img" element is never reached by graphic navigation — and it stays a literal column that never rolls. Passing the formatted string also means trendPercent renders exactly as the un-animated branch shows it, without Intl grouping a large value into 1,234.5.

const columns: TableColumn[] = [
  { id: 'plan', label: 'Plan', type: 'two-line-text' },
  { id: 'state', label: 'State', type: 'tag' },
  { id: 'revenue', label: 'Revenue', type: 'compare' },
  { id: 'active', label: 'Active', type: 'toggle', onToggle: (rowIndex, checked) => update(rowIndex, checked) }
];

const rows: TableRow[] = [
  {
    plan: { text1: 'Growth Monthly', text2: 'PLN-0042' },
    state: { text: 'Active', classes: 'pill-success' },
    revenue: { primary: '₹4,938.10', comparison: '₹4,100.00', trendPercent: 20 },
    active: { checked: true }
  }
];

Per-Column Header Metadata

Keyed columns carry their own header behavior: tooltip (hover text on the label), align ('left' | 'center' | 'right', applied to header and body cells), width (an inline fixed/preferred CSS width on the header and every body cell), maxWidth (caps the column; overflowing scalar cells ellipsize with the full value on the native title tooltip), highlighted (paints the column's header and body cells with the highlight wash — see --table-col-highlight-background; row hover and row selection still paint over it), and filter (a header dropdown — Table renders the Menu mechanics, the consumer owns options/selection/filtering; re-selecting the active option clears to null):

const columns: TableColumn[] = [
  { id: 'id', label: 'Order', width: '120px', maxWidth: '120px' },
  { id: 'name', label: 'Name', tooltip: 'Customer display name' },
  { id: 'amount', label: 'Amount', align: 'right', highlighted: true },
  {
    id: 'status', label: 'Status',
    filter: {
      options: [{ label: 'Active', value: 'active' }],
      selectedValue: currentFilter,
      onFilterChange: (value) => (currentFilter = value)
    }
  }
];

Sorting: getSortValue and server mode

column.getSortValue(row, rowIndex) supplies the comparable value for client-side sorting (currency/date parsing stays in the consumer): { id: 'amount', getSortValue: (row) => Number(String(row.amount).replace(/[₹,]/g, '')) }. Setting sortMode="server" keeps the header sort UI and onsort callback but skips the internal reorder — the consumer re-orders its rows (e.g. via a server query).

The standalone sortTableRows(rows, columnIndex, direction, options?) export sorts positional rows type-aware (numeric strings with thousands separators / percent / currency sort numerically; text case-insensitively; sortType: 'date' opt-in for dates, using range starts) with optional hasSummaryRow pinning and nestedKey extraction for object cells — useful for sortMode="server" consumers and unit tests.

Controlled sort (sortState)

sortMode="server" stops the internal reorder; it does not hand over the sort STATE. Pass sortState to own that too — a sort held in a URL, a saved view, or a server query restored into the built-in header:

<script>
  let sortState = $state({ columnId: 'amount', direction: 'desc' });
</script>

<Table
  {columns}
  {rows}
  sortMode="server"
  {sortState}
  onsortchange={(next) => {
    sortState = next;
    void refetch(next);
  }}
/>
  • Keyed by column ID, not column index. columnId is a TableColumn.id; positional tables (tableHeaders/tableData) have no declared identity, so their column ID is the index as a string ('1'). The distinction is the point: reorder or hide a column and an index-keyed sort would silently start sorting whichever field moved into that slot. With IDs, a reordered column keeps its sort, and a sorted column that is hidden sorts nothing at all rather than handing the sort to its neighbour.
  • Table never writes to it. A header click calls onsortchange({ columnId, direction }) — and the unchanged onsort(columnIndex, direction) — and nothing moves until the consumer feeds a new sortState back. The direction cycles ascending → descending → ascending exactly as the uncontrolled table does.
  • null is a value, not an absence. sortState={null} means "controlled, sorted by nothing"; omitting the prop entirely is what leaves Table owning its own sort state, unchanged for every existing consumer.
  • Independent of sortMode: 'client' still sorts locally from the controlled state, 'server' still never re-sorts a page the consumer already fetched.

Headless adapters (multi-sort, faceting, grouped headers)

sortState is deliberately one column. Multi-column sort, faceted filter counts, grouped/multi-row headers and column-visibility engines belong to a headless table library (TanStack Table and similar), not inside this component: keep that engine as the source of truth, render through Table, and feed its state in through sortState / searchConfig.searchTerm / checkboxSelection.selectedIds / pagination, using columns[].id as the shared column identity. Do not run two sort or page engines at once — set sortMode="server" and pagination.mode: 'server' so Table reports and renders while the engine decides. TanStack's pageIndex is zero-based and pagination.page is one-based: convert once, at that boundary, and not again inside onPageChange.

Built-in Pagination

pagination renders a footer paginator (range label, optional page-size selector, page controls). 'client' mode slices the rows internally — search and page-size changes snap back to page 1; 'server' mode leaves the supplied rows untouched (they are the current page) and drives the chrome from page/totalItems/hasMore, with isLoading disabling the controls during fetches. A consumer paginatorSlot takes precedence.

The page-size selector is a combobox, which takes no name from its displayed value, so Table names it Rows per page. Translate it, or tell two tables on one page apart, with labels.rowsPerPage; a paginatorSlot replaces the whole footer and so brings its own names. labels.rowsPerPage applies only to the Svelte Table: <sui-table> never renders the built-in paginator (see Web Component).

The controls wrap in a narrow container: when the page-size selector and the page buttons do not fit on one line (about 320px for a short page range, and wider as the page numbers gain digits), the selector moves above the buttons and the buttons flow onto further lines, so every control stays inside the Table and clickable instead of being clipped. While they fit on one line the layout is unchanged.

page is 1-indexed in both modes. An adapter over a zero-based engine (TanStack's pageIndex) converts once, here — not again inside its own onPageChange.

Who owns the page. In client mode Table does: it renders the last page that actually has rows, so a dataset that shrinks from outside — rows deleted, replaced, or refetched shorter while the reader is on page 5 — resolves to a real page with a truthful range instead of a blank page past the end. That resolution is display-side and fires no onPageChange, because nobody asked for a page change — and it does not overwrite the page the reader chose, so a dataset that shrinks and comes back (a refetch, a filter widening again) returns them to where they were rather than to page 1. In server mode the consumer does: page is authoritative and onPageChange is a request it may honour, delay, or refuse by simply not changing the prop.

Who owns the page size. In client mode, the built-in selector. In server mode, declaring pageSize takes ownership of it the same way checkboxSelection.selectedIds takes ownership of selection: onPageSizeChange becomes a request, and until the consumer answers by changing the prop, the range text keeps describing the page the server actually served rather than a page of rows nobody fetched. Omit pageSize in server mode to keep the older behaviour where the selector drives the chrome on its own.

showFooterOnSinglePage keeps that footer visible when the data fits on one page — the default hides it entirely, which is DataGrid parity but wrong for a call site whose page-size selector is how the merchant asks for more rows.

hideControls renders the range summary alone, suppressing both the page-size selector and the steppers as a single unit; it implies showFooterOnSinglePage, since a count-only footer has nothing to hide behind "already on the only page". To suppress only one of the two, use hidePageSizeSelector or hideSteppers instead — each defaults to false, works independently of the other, and independently of hideControls. Setting both together behaves exactly like hideControls (including the same showFooterOnSinglePage implication once both are true); hideControls remains a plain shorthand for that combination and existing consumers of it are unaffected.

<!-- A call site with its own working steppers elsewhere on the page: keep
     Table's range text and steppers, drop the duplicate size selector. -->
<Table
  {columns}
  {rows}
  pagination={{
    pageSize: 10,
    hidePageSizeSelector: true,
    testId: 'orders-paginator'
  }}
/>

The range span's data-pw/testID is derived as `${testId}-paginator-range` from the table's testId, falling back to `${pagination.testId}-range` only when the table has none. A table's testId is usually load-bearing (the built-in cell ids derive from it), so the derivation alone cannot give the range span an independent name — pass pagination.rangeTestId to do that; it wins over the derived id whenever it's set, and the derivation is unchanged when it's left unset:

<Table
  {columns}
  {rows}
  testId="orders-table"
  pagination={{ testId: 'orders-paginator', rangeTestId: 'orders-range' }}
/>
<!-- range span emits data-pw="orders-range", not "orders-table-paginator-range" -->

The range text itself uses a plain hyphen by default ("{from}-{to} of {total}") — override rangeLabel to use an en dash or any other format.

<Table
  {columns}
  {rows}
  rowNumberColumn
  pagination={{
    pageSize: 10,
    onPageChange: (page) => {},
    testId: 'orders-paginator',
    prevButtonTestId: 'orders-previous',
    nextButtonTestId: 'orders-next'
  }}
/>

rowNumberColumn prepends a 1-based, pagination-aware sequence column.

prevButtonTestId and nextButtonTestId forward unchanged to the paginator's previous and next controls (the latter is also used by cursor-mode's load-more control). They are omitted by default, so existing paginator test IDs remain unchanged.

Built-in Cell Test-ID Suffixes

A keyed column's testIdSuffixes customizes only the generated suffixes used by built-in renderers. The column's testId remains the prefix; suffixes that normally include a row or item index still append that index after the override. Omitted suffixes retain their exact existing defaults. Per-cell testId values remain authoritative for tag, toggle, select, input, and button renderers.

<Table
  {rows}
  columns={[
    {
      id: 'docs',
      label: 'Docs',
      type: 'link',
      testId: 'document',
      testIdSuffixes: { link: 'resource', copy: 'clipboard', linkCopied: 'copied-notice' }
    }
  ]}
/>

The link and copy controls above emit document-resource-{rowIndex} and document-clipboard-{rowIndex}. The transient copied message deliberately remains document-copied-notice with no row index, matching the existing link-copied behavior. Other defaults include icon-{iconIndex}, thumb, thumb-placeholder, tag-{itemIndex}, trend-up, trend-down, menu-{rowIndex}, menu-trigger-{rowIndex}, popup-{rowIndex}, and popup-trigger-{rowIndex}.

summaryRowIndex marks one row (by its index in the consumer-supplied rows, pre-sort/pre-filter) as a summary/period-total row: it gets the table-summary-row class and a distinct background from --table-summary-row-background (falling back to the regular cell background when the token is unset). Because the row is matched by its original position, the highlight survives sorting, searching, and pagination. Pair it with sortTableRows(..., { hasSummaryRow: true }) to also pin the row in place during client-side re-sorts.

<Table {columns} {rows} summaryRowIndex={0} />

Controlled Selection + Bulk Toolbar

checkboxSelection.selectedIds switches selection to controlled mode: Table renders from the consumer's set and never mutates it — onSelectionChange reports the would-be next set (required for cross-page-persistent selection under server pagination). Omitting it keeps the internal uncontrolled behavior exactly as before. getRowAttributes(rowId, rowIndex) spreads arbitrary attributes onto each row checkbox (rowIndex is -1 for the header select-all) — an escape hatch for consumer-specific attributes such as native test IDs. toolbarSlot renders a bulk-action bar above the table while the selection is non-empty; the library owns only placement, the content is consumer-rendered:

{#snippet bulkToolbar({ selectedIds })}
  <span>{selectedIds.size} selected</span>
  <Button text="Delete" onclick={() => deleteAll(selectedIds)} />
{/snippet}

<Table
  {columns}
  {rows}
  checkboxSelection={{ selectedIds: selection, onSelectionChange: (next) => (selection = next) }}
  toolbarSlot={bulkToolbar}
/>

Custom Cell Rendering

Use the cell snippet to render components (Pills, links, badges) inside cells instead of plain text:

<script>
  import { Table, Pill } from '@juspay/svelte-ui-components';
</script>

<Table
  tableHeaders={['Name', 'Status']}
  tableData={[
    ['Alice', 'Active'],
    ['Bob', 'Inactive']
  ]}
>
  {#snippet cell(value, rowIndex, colIndex)}
    {#if colIndex === 1}
      <Pill text={String(value)} classes={value === 'Active' ? 'pill-success' : 'pill-error'} />
    {:else}
      {value}
    {/if}
  {/snippet}
</Table>

Use stickyHeader to keep headers fixed while scrolling. Works with isTableScrollable (table's own scroll area) or a parent scroll container.

<Table
  stickyHeader
  isTableScrollable
  tableHeaders={['Name', 'Score']}
  tableData={largeDataset}
  --table-container-height="400px"
/>

Custom Sort Icons

Replace the default SVG chevron icons with custom snippets:

<Table tableHeaders={['Name', 'Score']} tableData={data}>
  {#snippet sortAscIcon()}<span>↑</span>{/snippet}
  {#snippet sortDescIcon()}<span>↓</span>{/snippet}
  {#snippet sortDefaultIcon()}<span>↕</span>{/snippet}
</Table>

Per-Column Widths

Control individual column widths via CSS using the classes prop and nth-child selectors:

/* app.css */
.my-table th:nth-child(1),
.my-table td:nth-child(1) {
  width: 200px;
}
.my-table th:nth-child(2),
.my-table td:nth-child(2) {
  width: 30%;
}
.my-table th:nth-child(3),
.my-table td:nth-child(3) {
  width: 100px;
}
<Table classes="my-table" tableHeaders={['Name', 'Email', 'Role']} tableData={data} />

For a uniform column width across all columns, use the --table-column-width CSS variable instead.

Empty State

Show a placeholder when the view has no rows. The snippet receives a TableEmptyContext saying WHY, because "no records yet" and "nothing matched your search" are different messages with different remedies — and once the built-in search owns the term, a consumer reading rows.length === 0 cannot tell them apart:

<Table {columns} {rows} searchConfig={{ placeholder: 'Search…' }}>
  {#snippet empty({ reason, searchTerm })}
    {#if reason === 'no-matches'}
      <p>No records match “{searchTerm}”.</p>
    {:else}
      <p>No records yet.</p>
    {/if}
  {/snippet}
</Table>

reason is 'no-matches' whenever a search term or a column filter is active — including under onsearchchange, where the consumer hands back an already-filtered empty page — and 'no-rows' otherwise. Declaring the snippet without parameters stays valid, so existing consumers are unaffected:

{#snippet empty()}
  <p>No records found.</p>
{/snippet}

The empty message renders in the table body, so the header, the caption and the horizontal scroll container stay mounted: the reader keeps the column labels and their scroll position.

Row activation vs. controls inside a cell

A clickable row (onrowclick) and interactive content inside a cell both want the same click and the same Enter. The two halves are handled differently, deliberately.

Clickable rows keep native row and cell semantics and receive a name from their readable source-row context, such as Growth Monthly. Duplicate captions receive a stable source-record suffix that survives sorting, filtering and pagination. labels.rowAction(rowLabel) can localize or customize that name; ordinary rows without an action remain unnamed containers for their cell content.

Keyboard is handled for you. The row activates on Enter/Space only when the ROW ITSELF has focus. A key pressed inside a cell control never reaches it, so typing a space in an editable cell types a space instead of opening the record, and Enter on a cell button fires only the button. Nothing to opt into, and no allowlist of "interactive" tags, which could never be complete for inputs, editable regions, custom elements or portaled controls.

Click is opt-out, because "click anywhere on the row" is the feature. Guarding click by event target would break clicking the row's own text, which is most of the row. Mark interactive content instead:

{#snippet actionsCell(row)}
  <button data-row-activation="ignore" onclick={() => approve(row.id)}>Approve</button>
  <a href={row.url} data-row-activation="ignore">Detail</a>
  <input data-row-activation="ignore" aria-label="Note" />
{/snippet}

The marking is inherited, so one on a wrapper covers everything inside it. Built-in cell types (type: 'button', 'toggle', 'select', 'input', 'action-group', 'popup-menu', …) already stop propagation themselves and need no marking. In-cell Menu/Select panels opened with usePortal render outside the row entirely, so their clicks never reach it either — mark the trigger, which does sit in the row. An unmarked control keeps bubbling exactly as before, so a consumer who intends both to fire is unaffected.

Loading, error and partial results

Fetching, retrying and deciding what a partial page means are caller-owned; Table renders rows and says when it has none. The composition that keeps the states coherent:

<!-- Busy on your own region, so the rows stay mounted: row identity, focus and
     scroll position all survive a refresh. Replacing the table with a spinner
     loses all three. -->
<div aria-busy={state === 'loading'}>
  {#if state === 'error'}
    <!-- Outside the scroll container, so a sideways-scrolled reader still sees it. -->
    <div role="alert">Could not load records. <button onclick={retry}>Retry</button></div>
  {/if}
  <Table {columns} {rows} pagination={{ pageSize: 20, isLoading: state === 'loading' }}>
    {#snippet empty({ reason, searchTerm })}
      <!-- An error is not an empty result: a failed fetch never established
           that there are no records, so let the alert own that state. -->
      {#if state !== 'error'}
        {reason === 'no-matches' ? `No records match “${searchTerm}”.` : 'No records yet.'}
      {/if}
    {/snippet}
  </Table>
</div>

pagination.isLoading disables the paginator and page-size selector during a fetch so a reader cannot queue a second page request against stale chrome. A partial result is a short page plus your own notice, not a different component — keeping the same table keeps the header and the row identities.

Mobile Record Cards

Below a 640px viewport, mobileCardLayout stacks each row into a bordered card of label/value pairs instead of scrolling the table sideways. Headers with sort or select-all controls remain visible and operative above the cards; passive headers retain their screen-reader-only relationships:

<Table {columns} {rows} mobileCardLayout />

This is opt-in and off by default: a table that silently changed layout at some width for every existing consumer, with no prop set, would be a breaking change to a published library. Turn it on per table where the horizontal-scroll default is the wrong fit for a narrow viewport.

Why this needs component support, not a CSS recipe. The common td::before { content: attr(data-label) } pattern works for a plain <table> a consumer marks up themselves, but it cannot work here: a <sui-table> consumer's stylesheet cannot add a rule inside the element's shadow root, so there is nowhere for that ::before to live. Table carries the column → label mapping itself and renders it as real markup, which is compiled into the shadow root exactly like the rest of the component's styles — so mobileCardLayout behaves identically on the Svelte component and through <sui-table>.

Why the label is a real, aria-hidden element and not generated content. Generated content (::before/attr()) cannot carry aria-hidden, and a stacked layout that keeps a real <table> underneath already lets a screen reader announce each cell's column header through the normal header/cell association — adding a second, unhidden visible label would announce that header text twice. So each cell gets a <span class="table-mobile-label" aria-hidden="true"> holding the same text as its column header: visible to a sighted reader as the in-card label, invisible to assistive tech, which still gets the header from the table structure itself.

Why the ARIA roles are restated. Stacking cells vertically means every table/thead/tbody/tr/th/td switches from its table-family display value to block, and several browser/assistive-technology combinations drop the implicit table semantics as soon as that happens. mobileCardLayout restates them explicitly (role="table", "rowgroup", "row", "columnheader", "cell") so the accessible structure is no worse than the plain table at any width — the roles are harmless duplicates at desktop width, and load-bearing once the layout collapses to cards.

The breakpoint is a fixed 640px, not a themable custom property: @media conditions cannot read CSS custom properties, so there is no var() to expose here. See the CSS Variables section below for card spacing and label styling tokens, and Web Component for the mobile-card-layout attribute.

Paginator Slot

Render a pagination control in a footer region below the table using the paginatorSlot snippet:

<script>
  import { Table } from '@juspay/svelte-ui-components';
  let page = $state(1);
</script>

<Table tableHeaders={['Name', 'Role']} tableData={rows}>
  {#snippet paginatorSlot()}
    <div style="display: flex; gap: 8px; justify-content: flex-end;">
      <button onclick={() => page--} disabled={page === 1}>Prev</button>
      <span>Page {page}</span>
      <button onclick={() => page++}>Next</button>
    </div>
  {/snippet}
</Table>

Row & Cell Test IDs

Use getRowTestId and getCellTestId to apply data-pw attributes for Playwright/E2E selectors:

<Table
  tableHeaders={['Name', 'Status']}
  tableData={rows}
  getRowTestId={(row, rowIndex) => `user-row-${rowIndex}`}
  getCellTestId={(row, cell, rowIndex) => `user-cell-${rowIndex}-${String(row[0])}`}
/>

Checkbox Row Selection

Pass checkboxSelection to render a leading checkbox column. Set selectionMode to 'single' to allow at most one row selected at a time.

<script>
  import { Table } from '@juspay/svelte-ui-components';

  let selectedIds = $state(new Set());
</script>

<!-- Multiple selection (default) -->
<Table
  tableHeaders={['Name', 'Department']}
  tableData={rows}
  checkboxSelection={{
    selectionMode: 'multiple',
    getRowId: (row, rowIndex) => String(row[0]),
    disabledRowIds: new Set(['Alice']),
    onSelectionChange: (ids) => {
      selectedIds = ids;
    }
  }}
/>

<!-- Single selection -->
<Table
  tableHeaders={['Name', 'Department']}
  tableData={rows}
  checkboxSelection={{
    selectionMode: 'single',
    onSelectionChange: (ids) => {
      selectedIds = ids;
    }
  }}
/>

disabledRowIds expects a Set<string> of row IDs that should render as disabled (unchecked, non-interactive). getRowId derives a stable string key from each row; when omitted the default key is the row's pre-sort positional index as a string.

Pass searchConfig to show a search input above the table. By default the table filters rows client-side across all columns. Pass onsearchchange to disable client-side filtering and delegate to the server instead.

The visible TERM is separately controllable: set searchConfig.searchTerm and the input renders from it and never mutates it, with searchConfig.onSearchTermChange reporting each would-be term for the consumer to accept. That is what lets a search restored from a URL appear in the built-in input. It is orthogonal to onsearchchange — that prop delegates the FILTERING, this one only the term, so a controlled term still filters client-side unless onsearchchange is also supplied. Omit searchTerm and the input owns its term exactly as before.

<script>
  let term = $state(new URL(location.href).searchParams.get('q') ?? '');
</script>

<Table
  {columns}
  {rows}
  searchConfig={{
    placeholder: 'Search users…',
    searchTerm: term,
    onSearchTermChange: (next) => (term = next)
  }}
/>
<!-- Server-side delegation: client filtering disabled, onSearchChange fires on every keystroke -->
<script>
  import { Table } from '@juspay/svelte-ui-components';
  let filteredRows = $state(allRows);
</script>

<!-- Client-side filtering (searchableColumnIndices restricts which columns are searched) -->
<Table
  tableHeaders={['Name', 'Email', 'Role']}
  tableData={rows}
  searchConfig={{
    placeholder: 'Search users…',
    searchableColumnIndices: [0, 2],
    testId: 'user-search'
  }}
/>
<Table
  tableHeaders={['Name', 'Email', 'Role']}
  tableData={filteredRows}
  searchConfig={{ placeholder: 'Search…' }}
  onsearchchange={(term) => {
    filteredRows = fetchRows(term);
  }}
/>

Editable Cells

Table accepts oncellchange for call-site compatibility but does not call it internally.

Close over your own handler inside the cell snippet. Its fourth argument, originalIndex, identifies the source row after sorting, filtering and client pagination. Existing three-argument snippets continue working. Name custom inputs and textareas from their column and a stable row identity; the selected/edited value is not the field name.

<script>
  import { Table } from '@juspay/svelte-ui-components';
  import { Input } from '@juspay/svelte-ui-components';

  let rows = $state(myData);
  const handleCellChange = (originalIndex, colIndex, newValue) => {
    const updated = rows[originalIndex].slice();
    updated[colIndex] = newValue;
    rows = rows.map((row, idx) => (idx === originalIndex ? updated : row));
  };
</script>

<Table tableData={rows} tableHeaders={['Name', 'Score']}>
  {#snippet cell(value, _rowIndex, colIndex, originalIndex)}
    <Input
      value={String(value ?? '')}
      ariaLabel="{colIndex === 0 ? 'Name' : 'Score'} for record {originalIndex + 1}"
      oninput={(newValue) => handleCellChange(originalIndex, colIndex, newValue)}
    />
  {/snippet}
</Table>

For multiline custom cells, use the same contextual name on the real textarea:

<Table tableData={rows} tableHeaders={['Title', 'Notes']}>
  {#snippet cell(value, _rowIndex, colIndex, originalIndex)}
    <Input
      useTextArea
      value={String(value ?? '')}
      ariaLabel="{colIndex === 0 ? 'Title' : 'Notes'} for record {originalIndex + 1}"
      oninput={(newValue) => handleCellChange(originalIndex, colIndex, newValue)}
    />
  {/snippet}
</Table>

Names and selection references

Built-in input, select and toggle cells default to a name such as Tier for Growth Monthly, derived from the column and the first readable non-control cell in that row. Duplicate row captions receive a stable source-record suffix. A cell's ariaLabel overrides this default; labels.cellEditor(columnLabel, rowLabel) customizes generated names and labels.pageSize names the page-size combobox. Defaults use the table title, caption or column labels to identify the page-size field.

Toggle cells expose one native input with switch semantics. They retain the Toggle's native keyboard activation, checked state and form behavior; the surrounding event boundary has no second control role.

Selection keys returned by checkboxSelection.getRowId are separate from generated DOM control IDs. Generated IDs are whitespace-free and scoped to the table instance, including for spaced/Unicode keys. Select-all references only actual selectable controls in the current rendered page. Valid custom IDs from getRowAttributes are retained and used in that reference list; supply stable IDs unique within the DOM scope. Blank, whitespace-bearing or conflicting IDs fall back to the managed ID.

With no getRowId, selection uses the original source index through client-side sorting, filtering and pagination. Supply unique stable record keys for server pages or source arrays whose identities/order change.

Props

Prop Type Required Default Description
tableTitle string | null No '' Optional title text displayed above the table.
tableHeaders string[] No [] Array of column header strings. Each header is clickable for sorting (when sortable).
tableData Array<JSONValue[]> No [] Array of row arrays. Each row is an array of cell values (string, number, or boolean). Columns correspond to tableHeaders by index.
sortable boolean No true When false, disables sorting on all columns. Sort buttons are hidden.
sortableColumns number[] No - Array of column indices that are sortable. When provided, only these columns show sort buttons. Other columns are non-sortable regardless of the sortable prop.
stickyHeader boolean No false When true, the header row sticks to the top during scroll. Works with isTableScrollable or any parent scroll container. Offset via --table-header-sticky-top.
isTableScrollable boolean No false When true, creates a bounded scroll area on the table container. Headers are automatically sticky. Use --table-container-height to set the scroll area height.
isContentScrollable boolean No false When true, individual cell content scrolls vertically if it overflows the fixed cell height.
testId string No - Value for the data-pw attribute on the table container, used for end-to-end testing selectors.
caption string No - Accessible caption for screen readers. Rendered as a visually hidden <caption> element; a non-empty caption also names the existing horizontal scroll group and any actual vertical-overflow group without adding tab stops.
focusHorizontalOverflow boolean No false Makes a captioned table's horizontal scroll group a Tab stop (tabindex="0") while it actually overflows sideways, so keyboard users can scroll a read-only table that has no focusable cells. Has no effect without a non-empty caption.
sortAscIcon Snippet No Two-tone chevron pair Custom snippet rendered for the ascending sort indicator. Default is the up/down chevron pair with the up half in currentColor and the down half in --table-sort-inactive-color.
sortDescIcon Snippet No Two-tone chevron pair Custom snippet rendered for the descending sort indicator. Default is the up/down chevron pair with the down half in currentColor and the up half in --table-sort-inactive-color.
sortDefaultIcon Snippet No SVG chevron pair Custom snippet rendered for columns that haven't been sorted yet. Default is the solid up/down chevron pair in --table-sort-inactive-color.
cell Snippet<[JSONValue, number, number, number]> No - Custom cell renderer. Receives (value, rowIndex, colIndex, originalIndex). The added source index stays stable through client transforms; existing three-parameter snippets keep working. When not provided, cells render the raw value as text.
empty Snippet<[TableEmptyContext]> No - Content to show when the view has no rows, inside a full-width table row so the header stays. Receives { reason, searchTerm } — 'no-rows' vs 'no-matches'; declaring it without parameters stays valid.
classes string No - CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles.
paginatorSlot Snippet No - Snippet rendered in a footer region below the table. Use for pagination controls, row count info, or any per-page UI.
getRowTestId (row: JSONValue[], rowIndex: number) => string No - Callback that returns a data-pw attribute value for each row <tr>. Useful for Playwright and other E2E test selectors.
getCellTestId (row: JSONValue[], column: JSONValue, rowIndex: number) => string No - Callback that returns a data-pw attribute value for each data cell <td>. Receives the full row, the cell value, and the row index.
checkboxSelection TableCheckboxSelectionConfig No - Opt-in checkbox row-selection column. See TableCheckboxSelectionConfig type below.
searchConfig TableSearchConfig No - Opt-in search bar rendered above the table. Client-side filtering is applied by default; pass onsearchchange to delegate filtering to the server. See TableSearchConfig type below.
columns TableColumn[] No - Keyed column model (preferred). When provided, columns/rows are normalized internally onto the same engine as tableHeaders/tableData, which are then ignored for that instance. See TableColumn type below and "Usage" above.
rows TableRow[] No - Keyed row data, addressed by TableColumn.id. Used with columns. Missing keys render as empty cells. See TableRow type below.
sortMode 'client' | 'server' No 'client' 'client' sorts rows internally on header click. 'server' keeps the header sort UI and onsort callback but skips the internal reorder — the consumer re-orders the data itself.
sortState TableSortState | null No - Controlled sort, keyed by column ID. Provided (including null, meaning "sorted by nothing"), Table renders the header state and any client-side reorder FROM it and never mutates it — a header click reports through onsortchange/onsort instead. Omitted, Table owns the sort exactly as before. See "Controlled sort" above.
pagination TablePaginationConfig No - Built-in footer paginator (range label, optional page-size selector, page controls). See TablePaginationConfig type below and "Built-in Pagination" above.
toolbarSlot Snippet<[{ selectedIds: Set<string> }]> No - Bulk-action bar rendered above the table while the checkbox selection is non-empty. The library owns only placement — content is entirely consumer-rendered. See "Controlled Selection + Bulk Toolbar" above.
rowNumberColumn boolean No false Prepends a sequential row-number column (1-based, pagination-aware).
rowNumberLabel string No '#' Header label for the row-number column.
summaryRowIndex number | null No null Index (into the consumer-supplied rows, pre-sort/pre-filter) of a summary/period-total row that renders with a distinct background (--table-summary-row-background). Matched by original position, so it survives sort/search/pagination.
headerTooltipIcon Snippet No - Icon snippet shown after each header label that has a tooltip. When set, the default underline affordance on those labels is dropped.
headerTooltipPosition TooltipPosition No 'top' Placement of every header tooltip bubble.
usePortal boolean No false When true, in-cell Select dropdowns and Menu popovers (action-group/popup-menu columns) are portaled to document.body and positioned fixed, so the table's own scroll/overflow container cannot clip them. Set on tables whose rows can sit near a scroll edge.
labels TableLabels No - Overrides for the accessible names Table generates itself (sort, filter, row/select-all checkboxes, search clear/close, rows-per-page selector). Every member is optional and falls back to an English default; rowsPerPage is the one that adds a name where there was none. See TableLabels below.
mobileCardLayout boolean No false Opt-in stacked "record card" layout below a 640px viewport, in place of the default horizontal scroll. See "Mobile Record Cards" above.

Snippets

Snippet Parameters Description
sortAscIcon none Custom ascending sort icon, replaces the default SVG chevron.
sortDescIcon none Custom descending sort icon, replaces the default SVG chevron.
sortDefaultIcon none Custom default (unsorted) sort icon, replaces the dimmed up/down chevron pair.
cell (value: JSONValue, rowIndex: number, colIndex: number) Custom cell renderer. When not provided, cells render the raw value as text.
empty TableEmptyContext ({ reason, searchTerm }) Content shown when the view has no rows, inside a full-width table row.
paginatorSlot none Content rendered in a footer region below the table (e.g. pagination controls, row count).

Events

Event Type Description
onrowclick (rowIndex: number, rowData: JSONValue[]) => void Fires when a data row is clicked. The row becomes focusable and keyboard-navigable when provided.
onsort (columnIndex: number, direction: SortDirection) => void Fires after a column sort is toggled. direction is 'asc' or 'desc'.
onsortchange (sortState: TableSortState) => void Fires with every onsort, carrying the same change keyed by column ID ({ columnId, direction }) so a consumer never has to resolve an index against a column list that may since have changed. Only ever reports a sorted state; clearing a sort is the consumer setting sortState to null.
oncellchange (rowIndex: number, colIndex: number, newValue: JSONValue) => void Accepted as a prop for type-checking at the call site, but not called by Table internally. Wire your handler directly inside the cell snippet instead — snippets run in consumer scope and already have your handler in closure. See "Editable Cells" recipe above.
onsearchchange (searchTerm: string) => void When provided, disables built-in client-side filtering and calls this callback on every search input change. Use to delegate filtering to the server. Requires searchConfig to be set.

CSS Variables

Override these custom properties to theme the component.

Title

Variable Default CSS Property Description
--table-title-margin 0 0 12px 0 margin Margin around the table title.
--table-title-font-size 18px font-size Font size of the table title.
--table-title-font-weight 600 font-weight Font weight of the table title.
--table-title-color inherit color Text color of the table title. A heading has no background of its own, so it inherits the surrounding text colour by default rather than hardcoding one — set this to override.
--table-title-font-family - font-family Font family of the table title.
--table-title-padding - padding Padding of the table title.
--table-tile-font-size 18px font-size Secondary fallback for the title font size — --table-title-font-size falls back to this before the 18px literal. Kept for backward compatibility; set --table-title-font-size directly for new code.

Container & Layout

Variable Default CSS Property Description
--table-border 1px solid #e5e7eb border Border of the table container.
--table-border-radius 8px border-radius Border radius of the table container.
--table-container-width 100% width Width of the table container.
--table-container-height 143px height Height of the scrollable table container (when isTableScrollable).
--table-container-overflow hidden overflow Overflow of the table container. hidden clips the corners to --table-border-radius; set auto to let a wide table scroll sideways in the container itself.
--table-width 100% width Width of the table element.
--table-border-collapse collapse border-collapse Border collapse mode of the table.
--table-scroll-scrim-width 32px width Width of the fade-out gradient hint shown at the leading/trailing edge of a horizontally scrollable table.
--table-scroll-scrim-color #ffffff background (gradient) Color the scroll scrim fades from — set to match the table's background when it isn't white.

Cell Grid

Variable Default CSS Property Description
--table-inner-border none border Border of individual table cells. Set to 1px solid #ccc for full grid.
--table-row-border 1px solid #f3f4f6 border-bottom Border on the bottom of each data row. Subtle row separators.
--table-row-last-border none border-bottom Border on the last data row. Set to match --table-row-border if needed.
--table-padding 12px 16px padding Padding inside table cells.
--table-text-align left text-align Text alignment inside table cells.
--table-column-width - width Sets a uniform width for all table columns. Unset lets the table auto-size columns.
--scrollable-column-height 20px height Height of scrollable cell content (when isContentScrollable).
--table-overflow-wrap - overflow-wrap Overflow-wrap behavior for cell text.
--table-word-break - word-break Word-break behavior for cell text.

Header Cells

Variable Default CSS Property Description
--table-header-background #f9fafb background-color Background color of header cells. Falls back to --table-header-border-bgcolor.
--table-header-font-size 13px font-size Font size of header cells.
--table-header-font-family - font-family Font family of header cells.
--table-header-font-weight 600 font-weight Font weight of header cells.
--table-header-letter-spacing 0.02em letter-spacing Letter spacing of header text.
--table-header-text-transform - text-transform Text transform of header cells (e.g. uppercase, capitalize).
--table-header-color #6b7280 color Text color of header cells. Falls back to --table-header-font-color.
--table-header-sticky-top 0 top Top offset for sticky headers. Use when a fixed navbar is above the table.
--table-header-border - border Border on header cells.
--table-header-border-bgcolor - background-color Fallback background for header cells when --table-header-background is unset.
--table-header-font-color - color Fallback text color for header cells when --table-header-color is unset.
--table-header-justify - justify-content Horizontal alignment of a header cell's label + sort-icon + tooltip-icon group.
--table-header-tooltip-underline - text-decoration Underline style on header labels that carry a tooltip, when headerTooltipIcon is not set.
--table-filter-active-color - color Header label/icon color while that column's filter dropdown is active (a selection is applied).

Data Cells

Variable Default CSS Property Description
--table-content-background - background-color Background color of data cells. Falls back to --table-content-border-bgcolor.
--table-content-font-size 14px font-size Font size of data cells.
--table-content-font-family - font-family Font family of data cells.
--table-content-color #111827 color Text color of data cells. Falls back to --table-content-font-color.
--table-col-highlight-background #f3f9ff background-color Background of a highlighted: true column's body cells. Row hover/selection paint over it.
--table-col-highlight-header-background falls back to --table-col-highlight-background background-color Background of a highlighted: true column's header cell.
--table-content-border-bgcolor #ffffff background-color Fallback background for data cells when --table-content-background is unset.
--table-content-font-color - color Fallback text color for data cells when --table-content-color is unset.

Built-in Cells

Variable Default CSS Property Description
--table-cell-icon-size 16px width, height Size of icons in icon-label cells and icon-capable button cells.
--table-cell-input-icon-size 16px width, height Size of the leading icon inside an input cell (iconUrl).
--table-interactive-width auto width Width of the wrapper around interactive built-in cells (toggle, select, input, button, action-group, popup-menu).
--table-cell-icon-color - color Color of icons in icon-label cells and icon-capable button cells.
--table-cell-icon-button-color - color Color of an icon-only button cell's ghost control.
--table-cell-icon-button-hover-background - background-color Hover background of an icon-only button cell's ghost control.
--table-cell-primary-color - color Ink of the primary line in two-line-text / image-two-line-text cells.
--table-cell-primary-font-size - font-size Font size of the primary line in two-line-text / image-two-line-text cells.
--table-cell-secondary-color - color Ink of the secondary line in two-line-text / image-two-line-text cells.
--table-cell-secondary-font-size - font-size Font size of the secondary line in two-line-text / image-two-line-text cells.
--table-cell-inline-gap - gap Horizontal gap between a leading icon/thumbnail and its label/text in a built-in cell.
--table-cell-line-gap - gap Vertical gap between the primary and secondary lines in a two-line cell.
--table-cell-thumb-size 32px width, height Size of the image-two-line-text cell's thumbnail image.
--table-cell-thumb-radius falls back to --radius (4px) border-radius Corner rounding of the thumbnail image.
--table-cell-thumb-placeholder-background - background-color Background of the thumbnail placeholder shown when imageUrl is unset or fails to load.
--table-cell-thumb-placeholder-color - color Ink/icon color of the thumbnail placeholder.
--table-cell-thumb-placeholder-font-size - font-size Font size of the thumbnail placeholder's fallback glyph.
--table-tag-array-gap - gap Gap between chips in a tag-array cell.
--table-link-color - color Text color of a link cell's anchor.
--table-link-decoration - text-decoration Text decoration of a link cell's anchor.
--table-link-copy-color - color Color of a link cell's copy-to-clipboard icon.
--table-link-copy-hover-background - background-color Hover background of a link cell's copy-to-clipboard icon.
--table-trend-up-color - color Ink of a compare cell's trend row when the trend is positive.
--table-trend-down-color - color Ink of a compare cell's trend row when the trend is negative.
--table-trend-flat-color - color Ink of a compare cell's trend row when trendPercent is 0 or only trendLabel is set.
--table-trend-gap - gap Gap between the trend arrow/icon and its text.
--table-trend-icon-size - width, height Size of the trend up/down arrow icon.

Row Numbers

Style the leading sequence column shown when rowNumberColumn is true.

Variable Default CSS Property Description
--table-row-number-col-width - width Width of the row-number header and data cells.
--table-row-number-align - text-align Text alignment of the row number.
--table-row-number-color - color Text color of the row number.

Bulk Toolbar

Style the bar rendered above the table by toolbarSlot while checkboxSelection is non-empty.

Variable Default CSS Property Description
--table-toolbar-background #f9fafb background-color Background of the toolbar bar.
--table-toolbar-border 1px solid #e5e7eb border Border of the toolbar bar.
--table-toolbar-border-radius falls back to --radius (4px) border-radius Corner rounding of the toolbar bar.
--table-toolbar-padding 8px 12px padding Inner padding of the toolbar bar.
--table-toolbar-gap - gap Gap between the toolbar's own content and the table below it, or within toolbarSlot's content.
--table-toolbar-margin-bottom - margin-bottom Space between the toolbar and the table.

A second search-input mode (searchConfig.displayMode: 'inline') — a trigger icon that expands into a text field, styled independently of the toolbar Search Bar above.

Variable Default CSS Property Description
--table-inline-search-trigger-padding - padding Padding of the collapsed search trigger icon.
--table-inline-search-icon-color - color Color of the search icon.
--table-inline-search-icon-size - width, height Size of the search icon.
--table-inline-search-input-width - width Width of the expanded text field.
--table-inline-search-gap - gap Gap between the icon and the expanded text field.
--table-inline-search-clear-color - color Color of the clear (✕) button icon.
--table-inline-search-clear-icon-size - width, height Size of the clear button icon.
--table-inline-search-clear-padding - padding Padding of the clear button's hit area.

Rows

Variable Default CSS Property Description
--table-row-background - background-color Background color of data rows.
--table-row-alt-background - background-color Background of even-numbered rows for striped effect. Falls back to --table-row-background.
--table-row-hover-background - background-color Background color of data rows on hover.
--table-row-selected-background #eff6ff background-color Background of selected rows (when checkboxSelection is active). Applied to both the <tr> and its <td> children.
--table-summary-row-background falls back to --table-content-background background-color Background of the summaryRowIndex row. Applied to both the <tr> and its <td> children so it wins over a themed cell background.
--table-focus-outline-color #3b82f6 outline Outline color for focused clickable rows and focused search inputs.

Sort Controls

Variable Default CSS Property Description
--table-sort-button-color inherit color Color of the sort button icon — paints the ACTIVE (sorted) chevron half via currentColor.
--table-sort-button-hover-color - color Color of the sort button icon on hover.
--table-sort-button-hover-background rgba(0,0,0,0.05) background-color Background of the sort button on hover.
--table-sort-icon-size 14px width, height Size of the sort indicator SVG icons.
--table-sort-active-color #1B85FF color Color of the active (sorted) chevron half.
--table-sort-inactive-color #C7C7C7 fill Fill of the inactive chevron halves: both halves when unsorted, and the non-sorted direction when a column is sorted.
--table-sort-hover-color #797979 fill Fill the inactive halves step to while the sort button is hovered.
--table-sort-idle-opacity 1 opacity Opacity of the default (unsorted) sort indicator. The design system draws sort glyphs solid — faintness comes from --table-sort-inactive-color; set below 1 only to restore the legacy fade.
--table-sort-idle-hover-opacity 1 opacity Opacity of the default sort indicator on hover (before a column is sorted).

Empty State

Variable Default CSS Property Description
--table-empty-padding 32px 24px padding Padding around the empty state content.
--table-empty-color #9ca3af color Text color of the empty state content.
Variable Default CSS Property Description
--table-footer-border 1px solid #e5e7eb border-top Top border of the footer region rendered by paginatorSlot.
--table-footer-padding 8px 16px padding Padding inside the footer region.
--table-footer-background transparent background-color Background color of the footer region.
--table-paginator-gap - gap Gap between the range text, page-size selector, and steppers in the built-in paginator (pagination).
--table-paginator-range-color - color Text color of the "{from}-{to} of {total}" range summary.
--table-paginator-range-font-size - font-size Font size of the range summary.
--table-paginator-size-width - width Width of the page-size Select.

Checkbox Selection

These variables style the leading checkbox column that appears when checkboxSelection is set. The column renders the library Checkbox in controlled mode; every --table-checkbox-* token below is bridged onto the matching --checkbox-* variable inside the column, so theming the table keeps working and an app-wide Checkbox theme is overridden only there.

Variable Default CSS Property Description
--table-checkbox-col-width 44px width Width of the checkbox column header and data cells.
--table-checkbox-col-padding 12px 12px padding Padding of the checkbox column cells.
--table-checkbox-size 18px width, height Size (width and height) of the checkbox box element.
--table-checkbox-border 2px solid #9ca3af border Border of the unchecked checkbox.
--table-checkbox-border-radius 4px border-radius Border radius of the checkbox box. Falls back to --radius when unset.
--table-checkbox-background transparent background-color Background of the unchecked checkbox.
--table-checkbox-hover-border-color #6b7280 border-color Border color of the checkbox on hover (when not disabled).
--table-checkbox-checked-background #2563eb background-color Background of the checked checkbox.
--table-checkbox-checked-border-color #2563eb border-color Border color of the checked checkbox.
--table-checkbox-checked-border 2px solid #2563eb border Whole border of the checked checkbox. Set it when the checked width must differ from 2px; it wins over --table-checkbox-checked-border-color.
--table-checkbox-indeterminate-background #2563eb background-color Background of the header checkbox in indeterminate (partial-select) state.
--table-checkbox-indeterminate-border-color #2563eb border-color Border color of the header checkbox in indeterminate state.
--table-checkbox-indeterminate-border 2px solid #2563eb border Whole border of the header checkbox in indeterminate state; wins over --table-checkbox-indeterminate-border-color.
--table-checkbox-disabled-opacity 0.4 opacity Opacity of a disabled checkbox row.
--table-checkbox-focus-ring 0 0 0 3px rgba(59,130,246,0.3) box-shadow Focus ring shown on the checkbox element when focused via keyboard.
--table-checkbox-icon-size 12px width, height Size of the checkmark / minus SVG icon inside the checkbox box.
--table-checkbox-icon-color #ffffff color Color of the checkmark / minus icon.

These variables style the search input rendered above the table when searchConfig is set.

Variable Default CSS Property Description
--table-search-gap 8px gap Gap between the search icon, input, and clear button.
--table-search-padding 8px 12px padding Padding inside the search bar container.
--table-search-border 1px solid #e5e7eb border Border of the search bar container.
--table-search-border-radius 8px border-radius Border radius of the search bar container.
--table-search-background #ffffff background-color Background of the search bar container.
--table-search-margin-bottom 8px margin-bottom Margin below the search bar, separating it from the table.
--table-search-icon-color #9ca3af color Color of the search magnifier icon.
--table-search-icon-size 16px width, height Size of the search magnifier icon.
--table-search-font-size 14px font-size Font size of the search input text.
--table-search-color #111827 color Text color of the search input.
--table-search-placeholder-color #9ca3af color Placeholder text color of the search input.
--table-search-focus-border-radius 2px border-radius Border radius of the focus-visible outline on the search input.
--table-search-clear-color #6b7280 color Color of the clear (✕) button icon.
--table-search-clear-hover-color #111827 color Color of the clear button icon on hover.
--table-search-clear-hover-background rgba(0,0,0,0.05) background-color Background of the clear button on hover.
--table-search-clear-icon-size 14px width, height Size of the clear button icon.
--table-scroll-scrim-transition-duration 0.2s transition Duration of the horizontal-scroll edge scrim's fade transition. Falls back through --motion-duration.
--table-scroll-scrim-transition-easing ease transition Easing curve of the horizontal-scroll edge scrim's fade transition. Falls back through --motion-easing.

Mobile Cards

These variables style the stacked card layout that mobileCardLayout switches on below 640px — see "Mobile Record Cards" above. --table-mobile-card-radius and --table-mobile-card-border also fall back through the same --radius/--table-border-shaped chains as the rest of the component, and --table-mobile-label-color carries a dark-theme override in theme-dark.css for the same reason --table-header-color does: it stands in for the header text once the header row itself is hidden.

Variable Default CSS Property Description
--table-mobile-card-border 1px solid #e5e7eb border Border around each stacked row card.
--table-mobile-card-radius falls back to --table-border-radius, then --radius (4px) border-radius Corner rounding of each row card.
--table-mobile-card-padding 12px padding Inner padding of each row card.
--table-mobile-card-gap 12px margin-bottom Space between consecutive row cards.
--table-mobile-label-gap 8px gap Gap between a cell's label and its value inside a card.
--table-mobile-label-width 40% flex-basis Width reserved for the label column inside each card row.
--table-mobile-label-font-weight 600 font-weight Font weight of the label text.
--table-mobile-label-color #6b7280 color Text color of the label. Has a dark-theme override.

Type Reference

TableLabels

Table names several controls it renders on the caller's behalf. Those names were hardcoded English, and sortable defaults to true, so a consumer shipping a non-English UI shipped English on controls they never wrote. labels overrides each one.

type TableLabels = {
  sortBy?: (header: string) => string; // default: `Sort by ${header}`
  filterBy?: (header: string) => string; // default: `Filter by ${header}`
  selectRow?: (rowId: string) => string; // default: `Select row ${rowId || 'non-selectable'}`
  selectionColumn?: string; // default: 'Row selection'
  pageNavigation?: string; // default: table title + ' pagination', or 'Pagination'
  selectAllRows?: string; // default: 'Select all rows'
  cellEditor?: (columnLabel: string, rowLabel: string) => string;
  rowAction?: (rowLabel: string) => string; // default: rowLabel
  clearSearch?: string; // default: 'Clear search'
  closeSearch?: string; // default: 'Close search'
  rowsPerPage?: string; // default: 'Rows per page'
};
<Table
  {columns}
  {rows}
  labels={{
    sortBy: (header) => `Trier par ${header}`,
    selectAllRows: 'Tout sélectionner'
  }}
/>

The members that depend on a column or a row are functions rather than templates with a placeholder, because a translator needs to decide where the header goes rather than fill the slot an English sentence happens to leave.

Members are independent: the example above translates sorting and select-all while leaving the filter trigger and the search buttons in English.

Search is not here. The search input has always been named by searchConfig.placeholder, which is the right place for it.

type SortDirection = 'asc' | 'desc';

// JSONValue is imported from 'type-decoder'
// JSONValue = string | number | boolean | null | JSONValue[] | { [key: string]: JSONValue }

type TableCheckboxSelectionConfig = {
  /** Activate the checkbox column. Defaults to true when the config object is present. */
  enabled?: boolean;
  /** 'single' allows at most one row selected at a time; 'multiple' (default) allows many. */
  selectionMode?: 'single' | 'multiple';
  /** Called whenever the selection set changes, receives the new set of selected row IDs. */
  onSelectionChange?: (selectedIds: Set<string>) => void;
  /** Stable record key; default is the original source index as a string. */
  getRowId?: (row: JSONValue[], rowIndex: number, originalIndex: number) => string;
  /** Rows whose IDs appear here render a disabled, non-interactive checkbox. */
  disabledRowIds?: Set<string>;
};

type TableSearchConfig = {
  /** Placeholder text for the search input. Default: 'Search…' */
  placeholder?: string;
  /** Restrict client-side filtering to these column indices. When omitted all columns are searched. */
  searchableColumnIndices?: number[];
  /** Value for the data-pw attribute on the search input element. */
  testId?: string;
  /** 'toolbar' (default) renders the bar above the table; 'inline' is a trigger that expands in the last header. */
  displayMode?: 'toolbar' | 'inline';
  /** Controlled search term: the input renders from it and never mutates it. Omitted, the input owns its term. */
  searchTerm?: string;
  /** Reports each would-be term, controlled or not. Unlike onsearchchange it does not disable client-side filtering. */
  onSearchTermChange?: (searchTerm: string) => void;
};

type TableSortState = {
  /** A TableColumn.id, or the column index as a string for positional tables. */
  columnId: string;
  direction: SortDirection;
};

type TableEmptyContext = {
  /** 'no-matches' when a search term or column filter is active; 'no-rows' otherwise. */
  reason: 'no-rows' | 'no-matches';
  /** The term currently filtering the view; '' when none is active. */
  searchTerm: string;
};

// Helper aliases the two declarations below build on. All are exported from
// the package alongside TableRow/TableColumn.
type TableCellValue = JSONValue;

type TableColumnType =
  | 'text'
  | 'tag'
  | 'text-tag'
  | 'two-line-text'
  | 'icon-label'
  | 'image-two-line-text'
  | 'tag-array'
  | 'avatar-stack'
  | 'compare'
  | 'toggle'
  | 'link'
  | 'select'
  | 'input'
  | 'button'
  | 'action-group'
  | 'popup-menu'
  | 'custom';

// Per-column overrides for the data-pw suffixes built-in renderers emit.
type TableBuiltinCellTestIdSuffixes = {
  icon?: string;
  thumbnail?: string;
  thumbnailPlaceholder?: string;
  tag?: string;
  trendUp?: string;
  trendDown?: string;
  menu?: string;
  menuTrigger?: string;
  popup?: string;
  popupTrigger?: string;
  link?: string;
  copy?: string;
  linkCopied?: string;
};

type TableColumnFilterConfig = {
  options: Array<{ label: string; value: string }>;
  selectedValue?: string | null;
  onFilterChange?: (value: string | null) => void;
};

// Keyed row shape for the keyed column model: cell values addressed by
// TableColumn.id instead of array position.
type TableRow = Record<string, TableCellValue>;

type TableColumn = {
  id: string;
  label: string;
  /** Built-in renderer selection; defaults to 'text'. */
  type?: TableColumnType;
  /** Per-column sort opt-out; defaults to the table-wide `sortable` prop. */
  sortable?: boolean;
  testId?: string;
  /** Column-scoped renderer, receiving (row, displayIndex, originalIndex). Required when type is 'custom'. */
  cell?: Snippet<[TableRow, number, number]>;
  tooltip?: string;
  align?: 'left' | 'center' | 'right';
  width?: string;
  maxWidth?: string;
  testIdSuffixes?: TableBuiltinCellTestIdSuffixes;
  /** Paints this column's header/body cells with the highlight wash. */
  highlighted?: boolean;
  filter?: TableColumnFilterConfig;
  /** Extracts the comparable value for client-side sorting (currency/date parsing stays in the consumer). */
  getSortValue?: (row: TableRow, rowIndex: number) => string | number | boolean;
  onToggle?: (rowIndex: number, checked: boolean, originalIndex: number) => void;
  onSelect?: (rowIndex: number, selectedId: string, originalIndex: number) => void;
  onInput?: (rowIndex: number, value: string, originalIndex: number) => void;
  onButtonClick?: (rowIndex: number, originalIndex: number) => void;
  onPrimaryAction?: (rowIndex: number, originalIndex: number) => void;
  onMenuAction?: (rowIndex: number, itemId: string, originalIndex: number) => void;
};

type TablePaginationConfig = {
  /** 'client' slices rows internally. 'server' leaves rows untouched and drives chrome from page/totalItems/hasMore. */
  mode?: 'client' | 'server';
  /** 1-indexed current page. Server mode: controlled by the consumer. */
  page?: number;
  /** Rows per page. Default 10. */
  pageSize?: number;
  /** Page-size selector options. Default [10, 25, 50, 100]; [] hides the selector. */
  pageSizeOptions?: number[];
  /** Total row count (server mode). Client mode derives it from the data. */
  totalItems?: number;
  hasMore?: boolean;
  /** Disables the paginator and page-size selector during a fetch. */
  isLoading?: boolean;
  /** Keeps the footer visible even on a single page. Default false. */
  showFooterOnSinglePage?: boolean;
  /** Range-summary-only footer; suppresses the page-size selector and steppers. Implies showFooterOnSinglePage. */
  hideControls?: boolean;
  hidePageSizeSelector?: boolean;
  hideSteppers?: boolean;
  /** Range text override; default "{from}-{to} of {total}". */
  rangeLabel?: (from: number, to: number, total: number) => string;
  /** Explicit data-pw for the range span; wins over the testId-derived default. */
  rangeTestId?: string;
  onPageChange?: (page: number) => void;
  onPageSizeChange?: (pageSize: number) => void;
  onLoadMore?: () => void;
  testId?: string;
  prevButtonTestId?: string;
  nextButtonTestId?: string;
};

Web Component

Known limitation: through <sui-table> the built-in paginator does not render. The wrapper must supply the paginator-slot snippet for the host to be able to fill it, and supplying it unconditionally suppresses the component's own default. Unlike the sort icons, that default is a whole Pagination subtree built from internal state, so it cannot be reproduced as slot fallback content. Pass your own paginator through slot="paginator-slot", or use the Svelte component directly.

labels.rowsPerPage therefore has no effect through <sui-table>.

Tag: <sui-table>

<sui-table table-title="Users" sortable sticky-header mobile-card-layout>
  <div slot="empty">No data found</div>
  <div slot="paginator-slot">
    <button>Prev</button>
    <span>Page 1</span>
    <button>Next</button>
  </div>
</sui-table>

mobile-card-layout is a plain boolean attribute like sortable and sticky-header above — its presence is enough to opt in, exactly as with the Svelte component's mobileCardLayout. See "Mobile Record Cards" for what it does and why it needed component support rather than a CSS recipe.

Web Component Events

onrowclick, onsort, onsortchange, and onsearchchange are available as JS properties, and each also dispatches a same-named DOM custom event (bubbles, composed) for a consumer who only calls addEventListener — rowclick's detail is { rowIndex, rowData, originalIndex }, sort's is { columnIndex, direction }, sortchange's is the TableSortState object ({ columnId, direction }), and searchchange's is the search-term string:

const table = document.querySelector('sui-table');
table.addEventListener('rowclick', (e) => {
  console.log(e.detail.rowIndex, e.detail.originalIndex);
});
table.addEventListener('sort', (e) => {
  console.log(e.detail.columnIndex, e.detail.direction);
});

Slots

Slot Name Maps to Snippet Description
empty empty Content shown when the view has no rows. Static markup here cannot see WHY it is empty — see the Svelte-only note below.
sort-asc-icon sortAscIcon Custom ascending sort icon; defaults to the table's own sort glyph.
sort-desc-icon sortDescIcon Custom descending sort icon; defaults to the table's own sort glyph.
sort-default-icon sortDefaultIcon Custom default (unsorted) sort icon.
paginator-slot paginatorSlot Footer content below the table, typically pagination controls. Through <sui-table> this slot is always supplied, so the built-in paginator never renders whether or not you assign content — see the limitation above.
toolbar-slot toolbarSlot Bulk-action bar shown above the table while the checkbox selection is non-empty. Static markup here cannot see WHICH rows are selected — see the Svelte-only note below.

Note: tableHeaders, tableData, and sortableColumns are arrays — set them via JavaScript properties. The cell, getRowTestId, and getCellTestId props are function-typed and only available via JavaScript.

Svelte-only: cell (receives (cellValue, rowIndex, colIndex)) and column.cell (receives (row, rowIndex, originalIndex)) take arguments, so they cannot be expressed as a named slot: a Web Component <slot> projects markup, it does not forward Svelte snippet parameters, so the arguments above would be silently dropped. Use the Svelte component directly when you need these.

toolbarSlot (receives { selectedIds: Set<string> }) and empty (receives { reason, searchTerm }) are the parameterized snippets <sui-table> still bridges, because both are usable without their argument — a static toolbar, a static "No records" message: assign one as a JavaScript property (el.toolbarSlot = snippet, el.empty = snippet) and it is rendered WITH its argument; fill slot="toolbar-slot" / slot="empty" with markup instead and it renders without them, so the static toolbar cannot tell which rows are selected and the static empty message cannot tell "no records" from "no matches". Assigning the property wins over the slot.

labels.selectionColumn names the row-selection column when single selection does not render a select-all control. Its default is Row selection; override it with localized text.

labels.pageNavigation names the built-in page-navigation landmark. It defaults to the table title followed by pagination when tableTitle is set, and Pagination otherwise. Give different tables distinct contextual names. This applies to the Svelte built-in paginator; the existing custom-element paginator limitation remains.

Plain tables

Use the Svelte PlainTable export for text columns and custom cell snippets. It supports positional and keyed rows, sorting, filtering, pagination, and selection. Its column type accepts text and custom. Use Table for the full built-in cell renderer set.

<script lang="ts">
  import { PlainTable } from '@juspay/svelte-ui-components';
</script>

<PlainTable columns={[{ id: 'name', label: 'Name' }]} rows={[{ name: 'Ada' }]} />