Table
Tables: columns, filters, sorting, selection, pagination, expansion, scrolling and server data.
When to use
Table displays records with the same fields, such as participants, orders, or tasks. Columns let you compare values, sort and filter data, and select rows for a bulk action. You can expand child records within the table. To navigate a hierarchy of sections, use Tree.
Pass records through dataSource. Supply a columns array or declare columns inside the table with Table.Column and Table.ColumnGroup. The grouping example shows nested columns.
Records and columns
Each record needs a unique stable key: record.key or rowKey. It links DOM, selection and expansion. Use a string or a final number, preserving the key when sorting, editing, and getting a new page.
| Problem | Setting | Example |
|---|---|---|
| Show typed entries | dataSource, columns, rowKey |
Regular table |
| Sort and filter locally | sorter, onFilter in column |
Filters and sorting |
| Select rows for action | rowSelection, selectedRowKeys |
Choice and Action |
| Show a hierarchy of records | children |
Tree rows |
| Load pages with application | mode="server", onChange |
Server mode |
| Open entry details | expandable |
Expandable Strings |
A string in dataIndex names a record key. An array gives the path to a nested value. The render snippet receives the record, its index among siblings, and the original value.
Set an explicit column key with a string or number. If key is omitted, Table uses dataIndex or, for a column without a field, its position. Give columns that can be reordered stable keys. Filter and sort events report string keys.
Use column to share column settings. The minWidth option sets the minimum width with tableLayout="auto". Use ellipsis for long text and set { showTitle: false } when a custom tooltip provides the full text. Purchase requests example.
Use shouldCellUpdate to compare a new record with the last accepted record when the cell content depends on specific fields. Replace a changed record with a new object. Task editing example.
Use hidden to change which columns the app displays. Sorting and filtering for a hidden column still apply. Column visibility example.
Use children to give several columns a shared header. The responsive option on a top-level column or group controls which viewport widths show it. Workload example.
Set colSpan or rowSpan to merge cells. For header cells, set spans on the column or return them from onHeaderCell. For data cells, return them from onCell. A span of zero skips a cell already covered by the merged cell. Release checklist example.
Use onRow and onHeaderRow to return HTML attributes and Svelte event handlers. The data row index is its position on the entire expanded page. The header row index starts at zero and corresponds to its level.
Sorting, filters and pages
In client mode, sorter orders records and onFilter checks them against the applied conditions. In server mode, the app handles requests in onChange and supplies the resulting page.
Set multiple on sortable columns to combine criteria. The highest priority is compared first. The app accepts sorters from the event and sets each column's sortOrder. The showSorterTooltip option displays the next action. Sort by team and task count.
Set children for nested filter options. With filterMode: 'tree', users can expand branches, and filterSearch helps them find an option. The title snippet receives the applied filters and sort orders. Find teams in a tree.
Use defaultFilteredValue for an initial condition. To control it in the app, pass filteredValue and update it from onChange. In a custom filterDropdown, change the draft with setSelectedKeys and apply it with confirm(). The getPopupContainer option sets the popup host. Numeric filter example.
filterIcon and filterDropdown also accept static content. If a custom filter applies a value without onFilter, onChange receives it and the rows stay visible. Other active filters still apply. An option’s filters[].text can contain a number or a snippet. Provide a filterSearch function to search rich labels.
The available states are bind:sorter, bind:filters, bind:current and bind:pageSize. The corresponding default props specify only the initial local state. The filter or sorting is reset by assigning it to the current state. Managed filters show such a reset separately.
After filtering, the table returns to the first page. Use pagination.placement to show pagination above the table, below it, or in both places. Both sets of controls share the page number and size. Pagination example.
In server mode, pass the current page dataSource, total and loading. Table itself does not execute the query. Server example uses a local simulator and model that discards stale results, repeats the last request, and is released on unmount.
Pass Spin options to loading to set a delay and description. Use undefined or null for dataSource while the result is unknown. An empty array represents a result with no records. Use locale for the labels and empty state of an individual table. Loading and empty state example.
Select, expand and scroll
Set rowSelection.type to checkbox for multiple rows or radio for a single row. In checkbox mode, use Shift to select a range, and use selections to add bulk commands. Selection modes example.
Set controlled keys in rowSelection.selectedRowKeys and update them from rowSelection.onChange. When loading pages from a server, preserveSelectedRowKeys keeps the selected records when dataSource changes. Table also supports bind:selectedRowKeys.
Use expandedRowRender to add a details row. The rowExpandable option determines which records can show details. The Nested table example shows a participant's tasks in a separate table within that row.
Place Table.EXPAND_COLUMN and Table.SELECTION_COLUMN in the column array to position the built-in controls. Set expandIcon on the expansion options or in ConfigProvider.table to render your own button. Use renderCell to wrap the standard selection control, for example in a tooltip. With forceRender, a draft survives collapsing the details as long as its row stays in the DOM. Participant notes example.
scroll.x sets the minimum table width, scroll.y limits the vertical scrolling area. fixed=true/start/end fixes columns at logical edges taking into account RTL; If there is not enough space, pinning is disabled. Scrolling example shows the header and columns within its scroll region.
Use caption or aria-label to name the table. The showHeader option controls column headers, and rowHoverable controls row highlighting. Apply styles with class/style, column.className, rowClassName, and component design tokens.
Use classNames and styles to style specific elements such as header and body cells. Both accept an object or a function of the table props. The components.body.row snippet can extend a row's markup. Pass the supplied attributes, child snippet, and ref to the native element to retain its events and measurements. Row styling example.
Table inherits ConfigProvider.prefixCls with the suffix -table. A non-empty local prefixCls specifies the full name of the wrapper, rows, cells, sort and filter elements; empty string/undefined return the general prefix. Checkbox, Pagination and Button resolve their common prefix regardless of Table. Table CSS prefixes also shows the expanded line editor, RTL and separate namespace CSS variables.
dropdownPrefixCls sets the filter list prefix, with -menu appended. The popup shell, Checkbox and Button inherit the shared prefix.
In the caption example, the caption snippet names both the table and its scroll region. role and aria-* apply to the table element, while id and data-* go on its inner container.
Changing names preserves the editor's DOM, text, focus, selection, and FormData, as well as selection, expand, page, sort, open filter draft, and scrolling. The theme.components.Table and marker ant-table-css-var tokens are not renamed along with the classes. Namespace theme.cssVar.prefix is set separately; The nested-border-top service variable uses the common provider prefix without dots. Light, dark and compact themes work without CSS variables. Changing the prefix preserves the height of the table, including its pagination.
Virtual scrolling and totals
Enable virtual and set numeric scroll.x and scroll.y in pixels to render a window of rows. Table measures the exact heights after hydration. Selection applies to the entire current page, including rows outside the window. Check runs example.
Get a TableRef with bind:this and call scrollTo with a vertical offset, a key, or a row index on the current page. Use onScroll to track the window's vertical position. The scrollToFirstRowOnChange option controls whether changes to sorting, filters, or pagination scroll back to the start.
Use the components.body snippet to render rows in your own scroll region. Pass info.ref and info.onScroll to the container to sync horizontal scrolling with the header and keep scrolling by key. Share rowKey and scroll through ConfigProvider.table. A local scroll replaces the shared object. Custom check list example.
The title, footer, and summary snippets receive the current page's records. Table.Summary renders totals in tfoot. The Table.Summary.Cell index includes visible selection and expansion columns. Set fixed: 'bottom' or fixed: 'top' in summary to pin the totals in a table with a scroll height or with sticky.
Use sticky to pin the header and an additional horizontal scrollbar as the page scrolls. Set getContainer to use a different scroll region. In the totals example, the report scrolls within its card and the total updates when you change pages.
Tree rows
Pass child records in the children array. If your data uses a different field, set expandable.childrenColumnName. Each key must be unique across the entire table, including collapsed branches. The release tasks example shows three levels of rows.
Set the initially expanded rows with defaultExpandedRowKeys, or expand the entire initial page with defaultExpandAllRows. If the application controls expansion, update expandedRowKeys inside expandable when onExpandedRowsChange fires. Use indentSize to set the indentation per level.
Row checkboxes are independent by default. With checkStrictly: false in rowSelection, selecting a parent also selects its available descendants. When only part of a branch is selected, the parent checkbox shows a mixed state. The header checkbox selects available rows on the current page, including descendants in collapsed branches.
Client-side sorting orders sibling rows at each level. Filtering checks records at every level. If a parent fails the filter, its branch is hidden. Pagination counts top-level rows, and descendants stay on their parent's page.
Examples
Name | Team | Tasks |
|---|---|---|
| Анна | Разработка | 18 |
| Борис | Дизайн | 9 |
| Вера | Поддержка | 0 |
| Глеб | Разработка | 24 |
| Дарья | Дизайн | 12 |
| Егор | Поддержка | 15 |
Regular table
columns, dataSource and the actual caption.
Basic.svelte<script lang="ts"> import { Table } from '@woodger/antd'; import { columns, members } from './data'; </script> <Table dataSource={(members)} columns={(columns)} caption={("Documentation Participants")} pagination={(false)} />data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Name | Team | Tasks | |
|---|---|---|---|
| Анна | Разработка | 18 | |
| Борис | Дизайн | 9 | |
| Вера | Поддержка | 0 |
Choice and action
Checkbox, disabled recording and saving keys between pages.
Selection.svelte<script lang="ts"> import { Button, Table, type TableKey } from '@woodger/antd'; import { columns, members } from './data'; let selected = $state<TableKey[]>([]); let result = $state(''); </script> <style> .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; } output { display: block; margin-top: 16px; } </style> <div class="actions"><Button disabled={!selected.length} onclick={() => { result = ("Processed by: " + String((selected.length)) + ""); }}>{("Process selected rows")}</Button> <Button onclick={() => { selected = []; result = ''; }} >{("Clear row selection")}</Button></div> <Table dataSource={(members)} columns={(columns)} caption={("Selection of participants")} defaultPageSize={3} rowSelection={{ getCheckboxProps: row => ({ disabled: !row.active, 'aria-label': `Select participant ${row.name}` }) }} bind:selectedRowKeys={selected} pagination={({ 'aria-label': "Participant Selection Pages" })} /> <output aria-label={("Select Rows Table")}>{(selected.join(', ') || '—')}{(result ? `; ${result}` : '')}</output>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Member | Tasks | |
|---|---|---|
| Anna | 18 | |
| Boris | 9 | |
| Vera | 0 | |
| Gleb | 24 | |
| Daria | 12 | |
| Egor | 15 |
Selection modes and commands
Switch to single selection or use the bulk actions menu.
SelectionModes.svelte<script lang="ts"> import { Flex, Switch, Table, type TableKey, type TableRowSelection } from '@woodger/antd'; import { members, type Member } from './data'; const switchId = $props.id(); let single = $state(false); let selectedRowKeys = $state<TableKey[]>([]); const rowSelection = $derived<TableRowSelection<Member>>({ type: single ? 'radio' : 'checkbox', selectedRowKeys, onChange: keys => { selectedRowKeys = keys; }, getCheckboxProps: member => ({ 'aria-label': (member.name), disabled: !member.active }), selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT, Table.SELECTION_NONE] }); function changeMode(next: boolean) { single = next; if (single) { selectedRowKeys = selectedRowKeys.slice(0, 1); } } </script> <Flex vertical gap="medium"> <Flex align="center" gap="small"> <Switch id={switchId} checked={single} onCheckedChange={changeMode} /> <label for={switchId}>{("Select one participant")}</label> </Flex> <Table aria-label={("Participant selection modes")} dataSource={members} columns={[ { key: 'name', title: ("Member"), rowScope: 'row', render: name }, { key: 'tasks', title: ("Tasks"), dataIndex: 'tasks', align: 'right' } ]} {rowSelection} size="small" pagination={false} /> </Flex> {#snippet name(member: Member)} {(member.name)} {/snippet}data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Release task | Assignee | |
|---|---|---|
| Prepare the release | Anna | |
| Update the guide | Anna | |
| Build the package | Boris | |
| Announce the release | Boris |
Tree rows
Expand the release tasks and try selecting an entire branch or individual rows.
<script lang="ts">
import { Flex, Switch, Table, type TableColumn } from '@woodger/antd';
interface Task {
key: string;
title: string;
owner: string;
children?: readonly Task[];
}
const switchId = $props.id();
const tasks: readonly Task[] = [
{
key: 'prepare',
title: "Prepare the release",
owner: 'Anna',
children: [
{
key: 'guide',
title: "Update the guide",
owner: 'Anna',
children: [
{ key: 'review', title: "Review the examples", owner: 'Vera' }
]
},
{ key: 'build', title: "Build the package", owner: 'Boris' }
]
},
{ key: 'announce', title: "Announce the release", owner: 'Boris' }
];
const columns: TableColumn<Task>[] = [
{ key: 'task', title: "Release task", dataIndex: 'title', rowScope: 'row' },
{ key: 'owner', title: "Assignee", dataIndex: 'owner' }
];
let linkedSelection = $state(true);
</script>
<Flex vertical gap="medium">
<Flex align="center" gap="small">
<Switch id={switchId} bind:checked={linkedSelection} />
<label for={switchId}>{("Link parent and child selection")}</label>
</Flex>
<Table
aria-label={("Release tasks")}
dataSource={(tasks)}
columns={(columns)}
expandable={{ defaultExpandedRowKeys: ['prepare'], expandRowByClick: true }}
rowSelection={{
checkStrictly: !linkedSelection,
getCheckboxProps: task => ({ 'aria-label': task.title })
}}
pagination={false}
/>
</Flex>
Team | ||
|---|---|---|
| Анна | Разработка | 18 |
| Борис | Дизайн | 9 |
| Вера | Поддержка | 0 |
| Глеб | Разработка | 24 |
| Дарья | Дизайн | 12 |
| Егор | Поддержка | 15 |
Filters and sorting
Comparator, onFilter and one TableChange object.
FilterSort.svelte<script lang="ts"> import { Table, type TableChange } from '@woodger/antd'; import { filterColumns, members, type Member } from './data'; let result = $state('—'); function changed(change: TableChange<Member>) { result = ("" + String((change.action)) + ": " + String((change.currentDataSource.map( row => row.name ).join(', '))) + ""); } </script> <style> output { display: block; margin-top: 16px; overflow-wrap: anywhere; } </style> <Table dataSource={(members)} columns={(filterColumns)} caption={("Filters and sorting of participants")} pagination={(false)} onChange={changed} /> <output aria-label={("Change Table")}>{result}</output>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Member | ||
|---|---|---|
| Anna | Development | 18 |
| Boris | Design | 9 |
| Vera | Support | 0 |
| Gleb | Development | 24 |
| Daria | Design | 12 |
| Egor | Support | 15 |
Sorting by multiple columns
Sort participants within each team. Team has the highest priority.
MultiSort.svelte<script lang="ts"> import { Button, Flex, Table, type TableChange, type TableColumn, type TableSorter } from '@woodger/antd'; import { members, type Member } from './data'; let sorters = $state<TableSorter[]>([]); const columns = $derived<TableColumn<Member>[]>([ { key: 'name', title: ("Member"), rowScope: 'row', render: name }, { key: 'team', title: ("Team"), render: team, sortOrder: columnOrder('team'), sorter: { compare: compareTeams, multiple: 2 } }, { key: 'tasks', title: ("Tasks"), dataIndex: 'tasks', align: 'end', sortOrder: columnOrder('tasks'), sorter: { compare: (a, b) => a.tasks - b.tasks, multiple: 1 } } ]); function columnOrder(key: string) { const criterion = sorters.find(sorter => sorter.columnKey === key); return criterion?.order ?? null; } function compareTeams(left: Member, right: Member) { const leftName = (left.team); const rightName = (right.team); return leftName.localeCompare(rightName, "en"); } function acceptSort(change: TableChange<Member>) { if (change.action === 'sort') { sorters = change.sorters ?? []; } } </script> {#snippet name(member: Member)}{(member.name)}{/snippet} {#snippet team(member: Member)}{(member.team)}{/snippet} <Flex vertical gap="medium"> <div> <Button disabled={!sorters.length} onclick={() => { sorters = []; }}> {("Reset sorting")} </Button> </div> <Table aria-label={("Tasks by team")} dataSource={members} {columns} showSorterTooltip={{ target: 'sorter-icon' }} onChange={acceptSort} size="small" pagination={false} /> </Flex>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Member | Team(1) Filter: |
|---|---|
| Boris | Design |
| Daria | Design |
Search in tree filters
Find a team in the filter. Reset restores the initial Design selection.
TreeFilters.svelte<script lang="ts"> import { Table, type TableColumn, type TableColumnTitleProps, type TableFilterOption } from '@woodger/antd'; import { members, type Member } from './data'; const wholeProduct = 'product'; const teamOptions: TableFilterOption[] = [ { text: productLabel, value: wholeProduct, children: [ { text: "Development", value: "Development" }, { text: "Design", value: "Design" } ] }, { text: "Support", value: "Support" } ]; function matchesTeam(input: string, option: TableFilterOption) { const label = option.value === wholeProduct ? "Product team" : String(option.value); return (label).toLocaleLowerCase().includes(input.trim().toLocaleLowerCase()); } const columns: TableColumn<Member>[] = [ { key: 'name', title: "Member", rowScope: 'row', render: name }, { key: 'team', title: teamHeading, render: team, filters: teamOptions, filterMode: 'tree', filterSearch: matchesTeam, defaultFilteredValue: ["Design"], filterResetToDefaultFilteredValue: true, onFilter: (value, member) => value === wholeProduct ? member.team !== "Support" : value === member.team } ]; </script> {#snippet productLabel()}<strong>{("Product team")}</strong>{/snippet} {#snippet name(member: Member)}{(member.name)}{/snippet} {#snippet team(member: Member)}{(member.team)}{/snippet} {#snippet teamHeading({ filters }: TableColumnTitleProps<Member>)} {@const count = filters.team?.length ?? 0} {("Team")}{#if count} ({count}){/if} {/snippet} <Table aria-label={("Participants by team")} dataSource={members} columns={(columns)} size="small" pagination={false} />data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Member | Tasks |
|---|---|
| Anna | 18 |
| Boris | 9 |
| Vera | 0 |
| Gleb | 24 |
| Daria | 12 |
| Egor | 15 |
Custom filter panel
Enter a minimum task count and apply the filter.
CustomFilter.svelte<script lang="ts"> import { Button, Checkbox, Flex, InputNumber, Table, type TableChange, type TableColumn, type TableFilterDropdownProps, type TableFilterValue } from '@woodger/antd'; import { members, type Member } from './data'; let popupHost = $state<HTMLDivElement>(); let minimum = $state<TableFilterValue[]>([]); let highlightOnly = $state(false); function meetsMinimum(value: TableFilterValue | undefined, member: Member) { return typeof value === 'number' && member.tasks >= value; } const columns = $derived<TableColumn<Member>[]>([ { key: 'name', title: ("Member"), rowScope: 'row', render: name }, { key: 'tasks', title: ("Tasks"), dataIndex: 'tasks', align: 'end', filteredValue: minimum, filterDropdown: thresholdPanel, filterIcon: '≥', render: tasks, filterDropdownProps: { placement: 'bottomRight' }, onFilter: highlightOnly ? undefined : meetsMinimum } ]); function acceptFilter(change: TableChange<Member>) { if (change.action === 'filter') { minimum = change.filters?.tasks ?? []; } } </script> <style> .filter-popup-host { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; } </style> {#snippet name(member: Member)}{(member.name)}{/snippet} {#snippet tasks(member: Member)} {#if highlightOnly && meetsMinimum(minimum[0], member)} <strong>{member.tasks}</strong> {:else} {member.tasks} {/if} {/snippet} {#snippet thresholdPanel(filter: TableFilterDropdownProps)} {@const draft = filter.selectedKeys[0]} <Flex vertical gap="small" style="padding: 12px"> <InputNumber aria-label={("Minimum task count")} min={0} precision={0} value={typeof draft === 'number' ? draft : null} onChange={value => filter.setSelectedKeys(typeof value === 'number' ? [value] : [])} /> <Flex gap="small" wrap> <Button size="small" type="primary" onclick={() => filter.confirm()}> {("Apply")} </Button> <Button size="small" onclick={() => filter.clearFilters({ confirm: true, closeDropdown: true })} > {("Reset")} </Button> </Flex> </Flex> {/snippet} <div class="filter-popup-host" bind:this={popupHost}> <Checkbox bind:checked={highlightOnly}> {("Highlight matches and keep all rows")} </Checkbox> <Table aria-label={("Filter by task count")} dataSource={members} {columns} locale={{ filterTitle: ("Threshold") }} getPopupContainer={trigger => popupHost ?? trigger.ownerDocument.body} onChange={acceptFilter} size="small" pagination={false} /> </div>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Team | ||
|---|---|---|
| Глеб | Разработка | 24 |
| Анна | Разработка | 18 |
Controllable filters
bind:sorter/filters, reset and software setting of state.
Controlled.svelte<script lang="ts"> import { Button, Table, type TableFilters, type TableSorter } from '@woodger/antd'; import { filterColumns, members } from './data'; let sorter = $state<TableSorter | null>({ columnKey: 'tasks', order: 'descend' }); let filters = $state<TableFilters>({ team: ["Development"] }); </script> <style> .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; } </style> <div class="actions"> <Button onclick={() => { sorter = null; filters = {}; }}> {("Reset filters and sorting")} </Button> <Button onclick={() => { sorter = { columnKey: 'tasks', order: 'ascend' }; filters = { team: [ "Design" ] }; }}>{("Show designers by task")}</Button> </div> <Table dataSource={(members)} columns={(filterColumns)} caption={("Managed Filters Table")} bind:sorter bind:filters pagination={(false)} />data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Name | Team | Tasks |
|---|---|---|
| Анна | Разработка | 18 |
| Борис | Дизайн | 9 |
| Вера | Поддержка | 0 |
Size and limits
small/medium/large and bordered; title - caption.
Size.svelte<script lang="ts"> import { Checkbox, RadioGroup, Table, type ComponentSize } from '@woodger/antd'; import { columns, members } from './data'; let size = $state<ComponentSize>('medium'); let bordered = $state(true); </script> <style>.settings { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }</style> <div class="settings" ><RadioGroup aria-label={("Table size")} bind:value={size} options={(['small', 'medium', 'large'])} /> <Checkbox bind:checked={bordered}>{("Table borders")}</Checkbox></div> <Table dataSource={(members.slice(0, 3))} columns={(columns)} {size} {bordered} caption={("Table size and boundaries")} pagination={(false)} />data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Name | Team | Tasks |
|---|---|---|
| Участник 1 | Разработка | 18 |
| Участник 2 | Дизайн | 9 |
| Участник 3 | Поддержка | 0 |
| Участник 4 | Разработка | 24 |
| Участник 5 | Дизайн | 12 |
| Участник 6 | Поддержка | 15 |
| Участник 7 | Разработка | 18 |
| Участник 8 | Дизайн | 9 |
| Участник 9 | Поддержка | 0 |
| Участник 10 | Разработка | 24 |
| Участник 11 | Дизайн | 12 |
| Участник 12 | Поддержка | 15 |
| Участник 13 | Разработка | 18 |
| Участник 14 | Дизайн | 9 |
| Участник 15 | Поддержка | 0 |
| Участник 16 | Разработка | 24 |
| Участник 17 | Дизайн | 12 |
| Участник 18 | Поддержка | 15 |
| Участник 19 | Разработка | 18 |
| Участник 20 | Дизайн | 9 |
| Участник 21 | Поддержка | 0 |
| Участник 22 | Разработка | 24 |
| Участник 23 | Дизайн | 12 |
| Участник 24 | Поддержка | 15 |
Dock and scroll
Inner scroll.y, horizontal scroll.x and fixed start/end.
Scroll.svelte<script lang="ts"> import { Checkbox, Table, type TableColumn } from '@woodger/antd'; import { members, type Member } from './data'; let fixed = $state(true); const rows = Array.from({ length: 24 }, (_, index) => ({ ...members[index % members.length], key: index, name: `Member ${index + 1}` })); const columns = $derived<TableColumn<Member>[]>([ { key: 'name', title: "Name", dataIndex: 'name', width: 180, fixed: fixed ? 'start' : false }, { key: 'team', title: "Team", dataIndex: 'team', width: 480 }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', width: 120, fixed: fixed ? 'end' : false } ]); </script> <style>.settings { margin-bottom: 16px; }</style> <div class="settings" ><Checkbox bind:checked={fixed} >{("Secure the outer columns")}</Checkbox></div> <Table dataSource={(rows)} columns={(columns)} caption={("Scrolling Table")} pagination={(false)} scroll={{ x: 900, y: 260 }} />data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
№ | Check | Time, s |
|---|---|---|
| 1 | Link check | 2 |
| 2 | Type checking | 3 |
| 3 | Example check | 4 |
| 4 | Link check | 5 |
| 5 | Type checking | 6 |
| 6 | Example check | 7 |
| 7 | Link check | 8 |
Virtual scrolling
Scroll through a thousand records or jump to the last by its key.
<script lang="ts">
import { Button, Flex, Table, type TableColumn, type TableRef } from '@woodger/antd';
interface CheckRun {
key: number;
title: string;
duration: number;
}
const runCount = 1_000;
const checks = ["Link check", "Type checking", "Example check"];
const runs = Array.from({ length: runCount }, (_, index): CheckRun => ({
key: index + 1,
title: checks[index % checks.length],
duration: 2 + index % 30
}));
const columns: TableColumn<CheckRun>[] = [
{ key: 'run', title: '№', dataIndex: 'key', rowScope: 'row', width: 72, fixed: 'start' },
{ key: 'check', title: "Check", dataIndex: 'title', width: 280 },
{ key: 'duration', title: "Time, s", dataIndex: 'duration', width: 128, align: 'right' }
];
let table = $state<TableRef>();
let scrolled = $state(false);
</script>
<Flex vertical gap="medium">
<Flex gap="small" wrap>
<Button disabled={!scrolled} onclick={() => table?.scrollTo({ top: 0 })}>
{("Back to the first row")}
</Button>
<Button onclick={() => table?.scrollTo({ key: runCount, align: 'end' })}>
{("Go to the last record")}
</Button>
</Flex>
<Table
bind:this={table}
aria-label={("Check runs")}
columns={(columns)}
dataSource={(runs)}
virtual
size="small"
scroll={{ x: 480, y: 230 }}
onScroll={event => { scrolled = event.currentTarget.scrollTop > 0; }}
pagination={false}
/>
</Flex>
№ | Check |
|---|
- 1Link check
- 2Type checking
- 3Example check
- 4Link check
- 5Type checking
- 6Example check
- 7Link check
- 8Type checking
- 9Example check
- 10Link check
- 11Type checking
- 12Example check
- 13Link check
- 14Type checking
- 15Example check
- 16Link check
- 17Type checking
- 18Example check
- 19Link check
- 20Type checking
- 21Example check
- 22Link check
- 23Type checking
- 24Example check
List with a custom scroll region
The header and scrolling by key work with a custom list.
<script lang="ts">
import { Button, ConfigProvider, Flex, Table, type TableBodyRenderInfo, type TableColumn }
from '@woodger/antd';
import type { TableRef } from '@woodger/antd';
interface Check {
id: number;
title: string;
}
const firstColumnWidth = 72;
const width = 480;
const height = 168;
const lastCheck = 24;
const kinds = ["Link check", "Type checking", "Example check"];
const checks = Array.from({ length: lastCheck }, (_, index): Check => ({
id: index + 1, title: kinds[index % kinds.length]
}));
const columns: TableColumn<Check>[] = [
{ key: 'id', title: '№', dataIndex: 'id', width: firstColumnWidth },
{ key: 'title', title: "Check", dataIndex: 'title', width: width - firstColumnWidth }
];
let table = $state<TableRef>();
</script>
{#snippet checksBody(records: readonly Check[], info: TableBodyRenderInfo)}
<div
role="region"
aria-label={("Check list")}
tabindex="0"
class="check-scroll"
style:block-size={`${height}px`}
{@attach info.ref}
onscroll={info.onScroll}
>
<ol
style:inline-size={`${width}px`}
style:--number-width={`${firstColumnWidth}px`}
>
{#each records as check (check.id)}
<li data-row-key={check.id}>
<span>{check.id}</span><span>{check.title}</span>
</li>
{/each}
</ol>
</div>
{/snippet}
<Flex vertical gap="medium">
<div>
<Button onclick={() => table?.scrollTo({ key: lastCheck, align: 'end' })}>
{("Go to the last record")}
</Button>
</div>
<ConfigProvider table={{ rowKey: 'id', scroll: { x: width, y: height } }}>
<Table
aria-label={("Check runs with a custom scroll region")}
dataSource={(checks)}
columns={(columns)}
components={{ body: checksBody }}
bind:this={table}
size="small"
pagination={false}
/>
</ConfigProvider>
</Flex>
<style>
.check-scroll { overflow: auto; }
ol {
list-style: none;
padding: 0;
margin: 0;
}
li {
display: grid;
grid-template-columns: var(--number-width) 1fr;
padding-block: 8px;
border-block-end: 1px solid var(--ant-color-border-secondary);
}
li span { padding-inline: 8px; }
</style>
Team | ||
|---|---|---|
| Анна | Разработка | 18 |
| Борис | Дизайн | 9 |
| Вера | Поддержка | 0 |
| Глеб | Разработка | 24 |
| Дарья | Дизайн | 12 |
| Егор | Поддержка | 15 |
Speaker composition
column.hidden hides cells while preserving sorting and filters.
Columns.svelte<script lang="ts"> import { Checkbox, Table } from '@woodger/antd'; import { filterColumns, members } from './data'; let tasks = $state(true); const columns = $derived(filterColumns.map(column => ({ ...column, hidden: column.key === 'tasks' && !tasks }))); </script> <style>.settings { margin-bottom: 16px; }</style> <div class="settings" ><Checkbox bind:checked={tasks} >{("Show task column")}</Checkbox></div> <Table dataSource={(members)} columns={(columns)} caption={("Table column composition")} pagination={(false)} />data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Supplier | Request description | Qty |
|---|---|---|
| Northern Engineering Works | Spare parts for scheduled equipment maintenance Spare parts for scheduled equipment maintenance | 12 |
| East Supply | Mounting kits for workstations Mounting kits for workstations | 8 |
Column widths and long text
Switch the layout algorithm. Hover over a request description to read it in full.
<script lang="ts">
import { Checkbox, Flex, Table, Tooltip, type TableColumnInput } from '@woodger/antd';
interface Request {
key: number;
supplier: { title: string };
title: string;
quantity: number;
}
const requests: Request[] = [
{
key: 1,
supplier: { title: "Northern Engineering Works" },
title: "Spare parts for scheduled equipment maintenance",
quantity: 12
},
{
key: 2,
supplier: { title: "East Supply" },
title: "Mounting kits for workstations",
quantity: 8
}
];
const columns: TableColumnInput<Request>[] = [
{ title: "Supplier", dataIndex: ['supplier', 'title'], ellipsis: true },
{
key: 0, title: "Request description", dataIndex: 'title', width: 172,
ellipsis: { showTitle: false }, render: requestTitle
},
{ title: "Qty", dataIndex: 'quantity', align: 'end', width: 86 }
];
let fixedLayout = $state(true);
</script>
{#snippet requestTitle(_request: Request, _index: number, value?: unknown)}
{#if typeof value === 'string'}
<Tooltip title={value} trigger={['hover', 'focus']}>
<span class="request-title" tabindex="0">{value}</span>
</Tooltip>
{/if}
{/snippet}
<Flex vertical gap="medium">
<Checkbox bind:checked={fixedLayout}>{("Fixed column widths")}</Checkbox>
<Table
aria-label={("Purchase requests")}
dataSource={(requests)}
columns={(columns)}
column={{ align: 'start', width: 128, minWidth: 116 }}
tableLayout={fixedLayout ? 'fixed' : 'auto'}
scroll={{ x: 386 }}
pagination={false}
/>
</Flex>
<style>
.request-title {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
Member | Workload | |
|---|---|---|
Team | Tasks | |
| Anna | Development | 18 |
| Boris | Design | 9 |
| Vera | Support | 0 |
| Gleb | Development | 24 |
| Daria | Design | 12 |
| Egor | Support | 15 |
Grouped and responsive columns
Table.ColumnGroup groups the Team and Tasks columns. Table.Column uses responsive to show the Access column from md upwards.
GroupedColumns.svelte<script lang="ts"> import { Table } from '@woodger/antd'; import { members, type Member } from './data'; </script> {#snippet name(member: Member)} {(member.name)} {/snippet} {#snippet team(member: Member)} {(member.team)} {/snippet} {#snippet access(member: Member)} {member.active ? ("Open") : ("Suspended")} {/snippet} <Table aria-label={("Participant workload")} dataSource={members} onHeaderRow={(_, level) => ({ 'data-header-level': level })} size="small" bordered pagination={false} > <Table.Column key="name" title={("Member")} rowScope="row" render={name} /> <Table.ColumnGroup key="work" title={("Workload")}> <Table.Column key="team" title={("Team")} render={team} /> <Table.Column key="tasks" title={("Tasks")} dataIndex="tasks" align="right" /> </Table.ColumnGroup> <Table.Column key="access" title={("Access")} render={access} responsive={['md']} /> </Table>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Section and task | Status | |
|---|---|---|
| Documentation | Check links | Ready |
| Update the guide | In progress | |
| Package | Build the package | Ready |
| Publish the release after the checks. | ||
Merged cells
A section spans multiple rows, and the note spans the table.
<script lang="ts">
import { Table, type TableColumn } from '@woodger/antd';
interface ChecklistItem {
key: string;
section: string;
title: string;
sectionRows: number;
ready?: boolean;
note?: boolean;
}
const items: ChecklistItem[] = [
{
key: 'links', section: "Documentation", title: "Check links", sectionRows: 2, ready: true
},
{
key: 'guide', section: "Documentation", title: "Update the guide", sectionRows: 0
},
{ key: 'build', section: "Package", title: "Build the package", sectionRows: 1, ready: true },
{
key: 'note', section: "Publish the release after the checks.", title: '',
sectionRows: 1, note: true
}
];
const columns: TableColumn<ChecklistItem>[] = [
{
key: 'section',
title: "Section and task",
rowScope: 'row',
render: section,
onHeaderCell: () => ({ colSpan: 2 }),
onCell: item => ({ rowSpan: item.sectionRows, colSpan: item.note ? 3 : 1 })
},
{
key: 'task', title: "Release task", dataIndex: 'title', colSpan: 0,
onCell: item => ({ colSpan: item.note ? 0 : 1 })
},
{
key: 'status', title: "Status", render: status,
onCell: item => ({ colSpan: item.note ? 0 : 1 })
}
];
</script>
{#snippet section(item: ChecklistItem)}
{(item.section)}
{/snippet}
{#snippet status(item: ChecklistItem)}
{item.ready ? ("Ready") : ("In progress")}
{/snippet}
<Table
aria-label={("Release checklist")}
columns={(columns)}
dataSource={(items)}
onRow={item => ({ 'data-check': item.key })}
bordered
size="small"
pagination={false}
/>
Name | Tasks | Action |
|---|---|---|
| Анна | 18 | |
| Борис | 9 | |
| Вера | 0 |
Editing a cell
The numeric cell accepts a new record when its task count changes.
Editable.svelte<script lang="ts"> import { Button, InputNumber, Table, type TableColumn } from '@woodger/antd'; import { members, type Member } from './data'; let rows = $state(members.map(row => ({ ...row }))); let editing = $state<number | null>(null); let draft = $state<number | null>(null); let result = $state(''); const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'tasks', title: "Tasks", render: tasks, shouldCellUpdate: (row, previous) => row.tasks !== previous.tasks }, { key: 'action', title: "Action", render: action } ]; function save(row: Member) { if (draft === null) { return; } const tasks = draft; rows = rows.map(item => item.key === row.key ? { ...item, tasks } : item); result = ("" + String((row.name)) + ": " + String((tasks)) + ""); editing = null; } </script> <style> .actions { display: flex; flex-wrap: wrap; gap: 8px; } output { display: block; margin-top: 16px; } </style> {#snippet tasks(row: Member)} {#if editing === row.key}<InputNumber aria-label={("Participant tasks " + String((row.name)) + "")} bind:value={draft} min={0} precision={0} style="width: 88px" /> {:else}{(row.tasks)}{/if} {/snippet} {#snippet action(row: Member)} <div class="actions" >{#if editing === row.key}<Button size="small" disabled={draft === null} onclick={() => save(row)} >{("Save ")}{row.name}</Button> <Button size="small" onclick={() => { editing = null; }} >{("Cancel ")}{row.name}</Button> {:else}<Button size="small" disabled={editing !== null} onclick={() => { editing = row.key; draft = row.tasks; }}>{("Change ")}{row.name}</Button>{/if}</div> {/snippet} <Table dataSource={(rows.slice(0, 3))} columns={(columns)} caption={("Editing Table Cells")} pagination={(false)} scroll={{ x: 460 }} /> <output aria-label={("Saved cell Table")}>{(result || '—')}</output>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Name | Team | Tasks | |
|---|---|---|---|
| Анна | Разработка | 18 | |
| Борис | Дизайн | 9 | |
| Вера | Поддержка | 0 | |
Nested table
An expanded details row shows the participant's tasks in a separate table.
Nested.svelte<script lang="ts"> import { Table, type TableColumn } from '@woodger/antd'; import { columns, members, type Member } from './data'; interface Task { key: number; title: string; } const tasks: TableColumn<Task>[] = [{ key: 'title', title: "Task name", dataIndex: 'title' }]; </script> {#snippet details(row: Member)} <Table dataSource={([{ key: 1, title: `Check components: ${row.name}` }])} columns={(tasks)} caption={("Tasks: " + String((row.name)) + "")} pagination={(false)} size="small" /> {/snippet} <Table dataSource={(members.slice(0, 3))} columns={(columns)} caption={("Nested tables")} expandable={{ expandedRowRender: details, defaultExpandedRowKeys: [1] }} pagination={(false)} />data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Name | Team | Tasks |
|---|---|---|
There are no participants in this table yet | ||
Empty data and loading
A local empty state and a delayed loading indicator.
Empty.svelte<script lang="ts"> import { Button, Checkbox, Empty, Table } from '@woodger/antd'; import { columns, members } from './data'; let loaded = $state(false); let loading = $state(false); const dataSource = $derived.by(() => { if (loaded) { return members; } return loading ? undefined : []; }); </script> <style>.settings { margin-bottom: 16px; }</style> {#snippet empty()}<Empty description={("There are no participants in this table yet")} ><Button style=" max-width: 100%; height: auto; white-space: normal; " onclick={() => { loaded = true; }} >{("Add demo lines")}</Button></Empty>{/snippet} <div class="settings" ><Checkbox bind:checked={loading} >{("Loading an empty table")}</Checkbox></div> <Table dataSource={(dataSource)} columns={(columns)} locale={{ emptyText: empty }} loading={{ spinning: loading, delay: 150, description: ("Participant workload") }} caption={("Empty table")} pagination={(false)} />data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Name | Team | Tasks |
|---|---|---|
| Анна | Разработка | 18 |
| Борис | Дизайн | 9 |
| Вера | Поддержка | 0 |
Pagination
Add pagination above the table and change the page using either set of controls.
Pagination.svelte<script lang="ts"> import { Checkbox, Table } from '@woodger/antd'; import { columns, members } from './data'; let current = $state(1); let pageSize = $state(3); let showTop = $state(false); </script> <style> .placement-control { margin-bottom: 16px; } output { display: block; margin-top: 16px; } </style> {#snippet total(count: number, range: [number, number])}{(range[0])}–{(range[1])}{(" from ")}{(count)}{/snippet} <div class="placement-control"> <Checkbox bind:checked={showTop}>{("Pagination above the table")}</Checkbox> </div> <Table dataSource={(members)} columns={(columns)} caption={("Pagination Table")} bind:current bind:pageSize pagination={({ 'aria-label': "Pagination example pages", placement: showTop ? ['topEnd', 'bottomEnd'] : ['bottomEnd'], showSizeChanger: true, pageSizeOptions: [3, 6], hideOnSinglePage: false, showTotal: total })} /> <output aria-label={("Page Table")}>{("Page: ")}{current}{("; lines: ")}{pageSize}</output>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Team | Status | |||
|---|---|---|---|---|
No data | ||||
Total: 0. Page: 1. Selected: 0.
Server mode
Snapshot query, cancel outdated query, error and retry. Data is simulated locally.
RemoteTableExample.svelte<script lang="ts"> import { onMount } from 'svelte'; import { Alert, Button, Checkbox, Table, type TableColumn, type TableKey } from '@woodger/antd'; import { createRemoteTable } from './remote-table.model.svelte'; import { createMemberSource, remoteTeams, type RemoteMember } from './remote-members'; const source = createMemberSource(); const remote = createRemoteTable(source.load); let selected = $state<TableKey[]>([]); let fixed = $state(true); let columns = $derived<TableColumn<RemoteMember>[]>([ { key: 'name', title: "Member", dataIndex: 'name', sorter: true, width: 200, fixed }, { key: 'team', title: "Team", dataIndex: 'team', width: 220, filters: remoteTeams.map((team) => ({ text: team, value: team })) }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', width: 160, sorter: true }, { key: 'active', title: "Status", render: memberStatus, width: 160, fixed: fixed ? 'end' : false, filterMultiple: false, filters: [{ text: "Active", value: true }, { text: "Suspended", value: false }] } ]); onMount(() => { void remote.load(); return remote.dispose; }); function showError() { source.failNextRequest(); void remote.load(); } </script> <style> .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; } .remote-status { margin: 16px 0 0; color: var(--ant-color-text-tertiary); font-size: 12px; } .error { margin-bottom: 16px; } .active { color: var(--ant-color-success); } </style> {#snippet memberStatus(member: RemoteMember)}<span class:active={member.active}>{(member.active ? "Active" : "Suspended")}</span>{/snippet} {#snippet retry()}<Button type="primary" onclick={remote.retry} >{("Repeat download")}</Button>{/snippet} <div class="actions"><Button onclick={() => { void remote.load(); }}> {("Update data")} </Button><Button onclick={showError} >{("Download error example")}</Button><Checkbox bind:checked={fixed} >{("Freeze header and columns")}</Checkbox></div> {#if remote.error}<div class="error"><Alert type="error" title={(remote.error)} action={retry} showIcon /></div>{/if} <Table mode="server" total={remote.total} dataSource={(remote.rows)} columns={(columns)} caption={("Deleted participants")} bind:current={remote.current} bind:pageSize={remote.pageSize} bind:sorter={remote.sorter} bind:filters={remote.filters} bind:selectedRowKeys={selected} rowSelection={{ fixed, getCheckboxProps: (member) => ({ disabled: !member.active, 'aria-label': `Select deleted participant ${member.key}` }) }} loading={remote.loading} onChange={remote.change} pagination={({ showSizeChanger: true, pageSizeOptions: [5, 10, 20], 'aria-label': "Pages of deleted participants" })} scroll={{ x: 900, y: fixed ? 300 : undefined }} /> <p class="remote-status" role="status" aria-label={("Result of remote download")} >{("Total: ")}{(remote.total)}{(". Page: ")}{(remote.current)}{(". Selected: ")}{(selected.length)}.</p>remote-table.model.svelte.tsimport type { TableChange, TableFilters, TableSorter } from '@woodger/antd'; import { getPaginationState } from '@woodger/antd'; export interface RemoteTableQuery { current: number; pageSize: number; sorter: TableSorter | null; filters: TableFilters; } export interface RemoteTablePage<Row extends object> { rows: readonly Row[]; total: number; } export type RemoteTableLoader<Row extends object> = ( query: RemoteTableQuery, signal: AbortSignal ) => Promise<RemoteTablePage<Row>>; function copyQuery(query: RemoteTableQuery): RemoteTableQuery { return { current: query.current, pageSize: query.pageSize, sorter: query.sorter ? { ...query.sorter } : null, filters: Object.fromEntries( Object.entries(query.filters).map(([key, values]) => [key, [...values]]) ) }; } export function createRemoteTable<Row extends object>( loadPage: RemoteTableLoader<Row>, initial: Partial<RemoteTableQuery> = {} ) { let current = $state(initial.current ?? 1); let pageSize = $state(initial.pageSize ?? 5); let sorter = $state<TableSorter | null>(initial.sorter ? { ...initial.sorter } : null); let filters = $state<TableFilters>( Object.fromEntries( Object.entries(initial.filters ?? {}).map(([key, values]) => [key, [...values]]) ) ); let rows = $state.raw<readonly Row[]>([]); let total = $state(0); let loading = $state(false); let error = $state<string | null>(null); let requestId = 0; let controller: AbortController | undefined; let disposed = false; let lastQuery = readQuery(); function readQuery(): RemoteTableQuery { return copyQuery({ current, pageSize, sorter, filters }); } async function load(query: RemoteTableQuery = readQuery()) { if (disposed) { return; } const id = ++requestId; controller?.abort(); const activeController = new AbortController(); controller = activeController; let pending = copyQuery(query); lastQuery = copyQuery(pending); current = pending.current; pageSize = pending.pageSize; sorter = pending.sorter ? { ...pending.sorter } : null; filters = copyQuery(pending).filters; rows = []; error = null; loading = true; try { while (true) { const page = await loadPage(copyQuery(pending), activeController.signal); if (disposed || id !== requestId) { return; } const paging = getPaginationState(page.total, pending.current, pending.pageSize); total = paging.total; current = paging.current; pageSize = paging.pageSize; if (pending.current !== paging.current || pending.pageSize !== paging.pageSize) { pending = { ...pending, current: paging.current, pageSize: paging.pageSize }; lastQuery = copyQuery(pending); continue; } rows = [...page.rows]; return; } } catch { if (!disposed && id === requestId) { error = "Failed to load data. Try again."; } } finally { if (!disposed && id === requestId) { loading = false; controller = undefined; } } } return { get current() { return current; }, set current(value: number) { current = value; }, get pageSize() { return pageSize; }, set pageSize(value: number) { pageSize = value; }, get sorter() { return sorter; }, set sorter(value: TableSorter | null) { sorter = value; }, get filters() { return filters; }, set filters(value: TableFilters) { filters = value; }, get rows() { return rows; }, get total() { return total; }, get loading() { return loading; }, get error() { return error; }, get query() { return readQuery(); }, load, retry() { return load(lastQuery); }, change(change: TableChange<Row>) { return load( { current: change.pagination.current, pageSize: change.pagination.pageSize, sorter: change.sorter, filters: change.filters ?? {} } ); }, dispose() { disposed = true; requestId++; controller?.abort(); controller = undefined; loading = false; } }; }remote-members.tsimport type { TableColumn } from '@woodger/antd'; import { getTableData } from '@woodger/antd'; import type { RemoteTableLoader } from './remote-table.model.svelte'; export interface RemoteMember { key: number; name: string; team: string; tasks: number; active: boolean; } export const remoteTeams = ["Development", "Design", "Support"]; export function createMemberSource() { let failNext = false; const members: RemoteMember[] = Array.from({ length: 36 }, (_, index) => ({ key: index + 1, name: `Member ${String(index + 1).padStart(2, '0')}`, team: remoteTeams[index % remoteTeams.length], tasks: index * 7 % 43, active: index % 5 !== 1 })); const columns: TableColumn<RemoteMember>[] = [ { key: 'name', title: "Member", sorter: (left, right) => left.name.localeCompare(right.name, 'ru') }, { key: 'team', title: "Team", filters: remoteTeams.map((team) => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", sorter: (left, right) => left.tasks - right.tasks }, { key: 'active', title: "Status", filters: [{ text: "Active", value: true }, { text: "Suspended", value: false }], onFilter: (value, row) => row.active === value } ]; const load: RemoteTableLoader<RemoteMember> = (query, signal) => { const fail = failNext; failNext = false; return new Promise((resolve, reject) => { signal.throwIfAborted(); const timer = setTimeout(() => { signal.removeEventListener('abort', cancel); if (fail) { reject(new Error('Demo request failed')); return; } const data = getTableData(members, columns, undefined, query.sorter, query.filters); const start = (query.current - 1) * query.pageSize; resolve( { rows: data.rows.slice(start, start + query.pageSize).map((row) => row.record), total: data.rows.length } ); }, 350); function cancel() { clearTimeout(timer); signal.removeEventListener('abort', cancel); reject(signal.reason); } signal.addEventListener('abort', cancel, { once: true }); }); }; return { load, failNextRequest() { failNext = true; } }; }
Member | Team | Tasks | ||
|---|---|---|---|---|
| Марина Белова | Разработка | 18 | ||
| Павел Громов | Дизайн | 9 | ||
| Нина Романова | Поддержка | 0 | ||
Revealed: 1. Selected: 0.
Expandable strings
Details, rowExpandable, selecting and saving expandable.expandedRowKeys between pages. The owner updates the keys via expandable.onExpandedRowsChange.
<script lang="ts">
import { Button, Table, type TableColumn, type TableKey } from '@woodger/antd';
interface Member {
key: number;
name: string;
team: string;
email: string;
tasks: number;
active: boolean
}
const members: Member[] = [
{
key: 1,
name: "Marina Belova",
team: "Development",
email: 'marina@example.com',
tasks: 18,
active: true
},
{
key: 2,
name: "Pavel Gromov",
team: "Design",
email: 'pavel@example.com',
tasks: 9,
active: true
},
{
key: 3,
name: "Nina Romanova",
team: "Support",
email: 'nina@example.com',
tasks: 0,
active: false
},
{
key: 4,
name: "Oleg Krylov",
team: "Development",
email: 'oleg@example.com',
tasks: 24,
active: true
},
{
key: 5,
name: "Svetlana Morozova",
team: "Design",
email: 'svetlana@example.com',
tasks: 12,
active: true
},
{
key: 6,
name: "Timur Zaitsev",
team: "Support",
email: 'timur@example.com',
tasks: 15,
active: true
}
];
const columns: TableColumn<Member>[] = [
{ key: 'name', title: "Member", dataIndex: 'name', width: 220, fixed: true },
{ key: 'team', title: "Team", dataIndex: 'team', width: 360 },
{
key: 'tasks',
title: "Tasks",
dataIndex: 'tasks',
width: 120,
align: 'right',
fixed: 'end'
}
];
let expanded = $state<TableKey[]>([1]);
let selected = $state<TableKey[]>([]);
let current = $state(1);
let pageSize = $state(3);
</script>
<style>
.actions { margin-bottom: 20px; }
.details {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
gap: 16px;
margin: 0;
}
.details > div { min-width: 0; }
dt {
margin-bottom: 4px;
color: var(--ant-color-text-tertiary);
font-size: 12px;
}
dd { margin: 0; }
.state {
margin: 16px 0 0;
color: var(--ant-color-text-tertiary);
font-size: 12px;
}
</style>
{#snippet details(member: Member)}
<dl class="details" aria-label={("Participant information " + String((member.key)) + "")}>
<div><dt>{("Member")}</dt><dd>{member.name}</dd></div>
<div><dt>Email</dt><dd>{member.email}</dd></div>
<div><dt>{("Team")}</dt><dd>{(member.team)}</dd></div>
<div><dt>{("Open tasks")}</dt><dd>{(member.tasks)}</dd></div>
</dl>
{/snippet}
<div
class="actions"
><Button
onclick={() => { expanded = []; }}
disabled={!expanded.length}
>{("Collapse all details")}</Button></div>
<Table
dataSource={(members)}
columns={(columns)}
caption={("Participant cards")}
expandable={{
expandedRowRender: details,
rowExpandable: (member) => member.active,
fixed: true,
expandedRowKeys: expanded,
onExpandedRowsChange: keys => { expanded = keys; }
}}
rowSelection={{
fixed: true,
getCheckboxProps: (member) =>
({ disabled: !member.active, 'aria-label': `Select card ${member.key}` })
}}
bind:selectedRowKeys={selected}
bind:current
bind:pageSize
pagination={({
'aria-label': "Participant Card Pages",
showSizeChanger: true,
pageSizeOptions: [3, 6]
})}
scroll={{ x: 1000, y: 380 }}
/>
<p class="state" role="status" aria-label={("Card Reveal")}>{("Revealed: ")}{(expanded.length)}{(". Selected: ")}{(selected.length)}.</p>
Member | Note | |
|---|---|---|
| Anna | Anna | |
| Boris | Boris | |
| Vera | Vera | |
Service columns and expansion
Open a note, type a draft, and collapse the row. Your draft is kept.
CustomDetails.svelte<script lang="ts"> import { Button, ConfigProvider, Input, Table, Tooltip, type TableColumn, type TableExpandIconInfo } from '@woodger/antd'; import type { Snippet } from 'svelte'; import { members, type Member } from './data'; const dataSource = members.slice(0, 3); const columns = $derived<TableColumn<Member>[]>([ { key: 'name', title: ("Member"), rowScope: 'row', render: name }, Table.EXPAND_COLUMN, Table.SELECTION_COLUMN ]); </script> {#snippet name(member: Member)} {(member.name)} {/snippet} {#snippet expandIcon(info: TableExpandIconInfo)} {#if info.expandable} <Button type="link" size="small" disabled={info.disabled} aria-expanded={info.expanded} aria-controls={info.ariaControls} onclick={info.onExpand} > {info.expanded ? ("Hide note") : ("Open note")} </Button> {/if} {/snippet} {#snippet details(member: Member)} <Input name={`note-${member.key}`} aria-label={("Note draft")} placeholder={("Note about the participant")} /> {/snippet} {#snippet selectionCell(_checked: boolean, member: Member, _index: number, checkbox: Snippet)} <Tooltip title={(member.name)}> {@render checkbox()} </Tooltip> {/snippet} <ConfigProvider table={{ expandable: { expandIcon } }}> <Table aria-label={("Participant notes")} {columns} {dataSource} expandable={{ expandedRowRender: details, columnTitle: ("Note"), rowExpandable: member => member.active, forceRender: true, expandRowByClick: true }} rowSelection={{ columnWidth: 60, getCheckboxProps: member => ({ 'aria-label': (member.name) }), renderCell: selectionCell }} size="small" pagination={false} /> </ConfigProvider>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Team | ||
|---|---|---|
| Анна | Разработка | 18 |
| Борис | Дизайн | 9 |
| Вера | Поддержка | 0 |
Panels, headers and rows
title/footer get the current page; showHeader, rowHoverable, rowClassName and rowScope.
Panels.svelte<script lang="ts"> import { Checkbox, Table } from '@woodger/antd'; import type { TableColumn } from '@woodger/antd'; import { filterColumns, members, type Member } from './data'; let showHeader = $state(true); let rowHoverable = $state(true); const columns: TableColumn<Member>[] = filterColumns.map( column => column.key === 'name' ? { ...column, rowScope: 'row', className: 'table-member-name' } : column ); </script> <style> .settings { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; } .example :global(.table-member-name) { font-weight: 600; } .example :global(.table-inactive) { color: var(--ant-color-text-disabled); } </style> <div class="settings"> <Checkbox bind:checked={showHeader}>{("Table column headings")}</Checkbox> <Checkbox bind:checked={rowHoverable}>{("Table row highlighting")}</Checkbox> </div> <div class="example"> <Table dataSource={(members)} columns={(columns)} {showHeader} {rowHoverable} rowClassName={record => record.active ? '' : 'table-inactive'} defaultPageSize={3} > {#snippet caption()} <strong>{("Table panels and rows")}</strong> {/snippet} {#snippet title(rows: readonly Member[])} <span role="status" aria-label={("Current Page Table")}>{rows.map( row => row.name ).join(', ')}</span> {/snippet} {#snippet footer(rows: readonly Member[])} <span role="status" aria-label={("Table Page Summary")}>{("Tasks on the page: ")}{(rows.reduce( ( sum, row ) => sum + row.tasks, 0 ))}</span> {/snippet} </Table> </div>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Member | Team | Tasks |
|---|---|---|
| Anna | Development | 18 |
| Boris | Design | 9 |
| Vera | Support | 0 |
| Total tasks on this page | 27 | |
Pinned header and totals
Scroll the report inside the card. The total updates with the page.
SummarySticky.svelte<script lang="ts"> import { Table, type TableColumn } from '@woodger/antd'; import { members, type Member } from './data'; const columns: TableColumn<Member>[] = [ { key: 'name', title: "Member", render: name, width: 144 }, { key: 'team', title: "Team", render: team, width: 252 }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', width: 114 } ]; let report = $state<HTMLDivElement>(); </script> {#snippet name(member: Member)} {(member.name)} {/snippet} {#snippet team(member: Member)} {(member.team)} {/snippet} {#snippet summary(page: readonly Member[])} {@const taskCount = page.reduce((sum, member) => sum + member.tasks, 0)} <Table.Summary> <Table.Summary.Row> <Table.Summary.Cell index={0} colSpan={2}> {("Total tasks on this page")} </Table.Summary.Cell> <Table.Summary.Cell index={2} align="end">{taskCount}</Table.Summary.Cell> </Table.Summary.Row> </Table.Summary> {/snippet} <div class="report-scroll" role="region" aria-label={("Scroll report")} tabindex="0" bind:this={report} > <Table aria-label={("Tasks by participant")} columns={(columns)} dataSource={members} defaultPageSize={3} scroll={{ x: 510 }} sticky={{ getContainer: () => report }} summary={{ fixed: 'bottom', render: summary }} /> </div> <style> .report-scroll { max-block-size: 200px; overflow: auto; } </style>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Member | Tasks |
|---|---|
| Anna | 18 |
| Boris | 9 |
| Vera | 0 |
| Gleb | 24 |
| Daria | 12 |
| Egor | 15 |
Styling table elements
Compact cells with styles and a row with an extra HTML attribute.
SemanticElements.svelte<script lang="ts"> import { Checkbox, ConfigProvider, Flex, Table, type TableColumn, type TableElementRenderInfo } from '@woodger/antd'; import { members, type Member } from './data'; const columns: TableColumn<Member>[] = [ { key: 'name', title: "Member", rowScope: 'row', render: name }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'end' } ]; let compact = $state(false); </script> {#snippet name(member: Member)}{(member.name)}{/snippet} {#snippet workloadRow({ attributes, children, ref }: TableElementRenderInfo<'tr'>)} <tr {...attributes} data-workload-row="" {@attach ref}> {@render children()} </tr> {/snippet} <Flex vertical gap="medium"> <Checkbox bind:checked={compact}>{("Compact cells")}</Checkbox> <ConfigProvider table={{ classNames: { header: { cell: 'workload-heading' } } }}> <Table aria-label={("Workload table styling")} dataSource={members} columns={(columns)} components={{ body: { row: workloadRow } }} onRow={member => ({ 'data-unassigned': member.tasks === 0 ? '' : undefined })} styles={{ body: { cell: compact ? 'padding-block: 6px' : undefined } }} pagination={false} /> </ConfigProvider> </Flex> <style> :global(.workload-heading) { background: var(--ant-color-fill-tertiary); } tr[data-unassigned] { font-weight: 600; } </style>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Team | ||||
|---|---|---|---|---|
| Анна | Разработка | 18 | ||
| Борис | Дизайн | 9 | ||
| Вера | Поддержка | 0 |
Name | Team | Tasks |
|---|---|---|
| Анна | Разработка | 18 |
Component theme
Header, cell and footer tokens, row selection, dimensions, nested theme and RTL.
Theme.svelte<script lang="ts"> import { Checkbox, ConfigProvider, RadioGroup, Table } from '@woodger/antd'; import type { ComponentSize } from '@woodger/antd'; import { columns, filterColumns, members, type Member } from './data'; let enabled = $state(true); let size = $state<ComponentSize>('large'); </script> <style> .settings { display: grid; gap: 16px; margin-bottom: 24px; } .nested { margin-top: 24px; } </style> <div class="settings"> <Checkbox bind:checked={enabled}>{("Apply Table tokens")}</Checkbox> <RadioGroup aria-label={("Size Thematic Table")} bind:value={size} options={(['large', 'medium', 'small'])} /> </div> <ConfigProvider direction="rtl" theme={{ components: { Table: enabled ? { headerBg: '#fff7e6', headerColor: '#874d00', cellPaddingBlock: 24, cellPaddingInline: 28, cellPaddingBlockMD: 22, cellPaddingInlineMD: 26, cellPaddingBlockSM: 8, cellPaddingInlineSM: 12, rowSelectedBg: '#fff1b8', rowExpandedBg: '#fffbe6', rowHoverBg: '#fff7e6', footerBg: '#fff7e6', footerColor: '#874d00', filterDropdownBg: '#fffbe6', selectionColumnWidth: 44 } : {} } }}> <Table dataSource={(members.slice(0, 3))} columns={(filterColumns)} {size} caption={("Table Component Theme")} rowSelection defaultSelectedRowKeys={[1]} pagination={(false)} expandable={{ expandedRowRender: details }} > {#snippet footer(rows: readonly Member[])}{("Participants: ")}{(rows.length)}{/snippet} </Table> <div class="nested"> <ConfigProvider theme={{ inherit: false, components: { Table: { headerBg: '#f6ffed', cellPaddingBlock: 6 } } }}> <Table dataSource={(members.slice(0, 1))} columns={(columns)} size="large" caption={("Isolated Table Theme")} pagination={(false)} style="border-radius:14px" /> </ConfigProvider> </div> </ConfigProvider> {#snippet details(record: Member)}{("Participant details: ")}{record.name}{/snippet}data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
Local prefixCls specifies the full name of the Table, dropdownPrefixCls specifies the base name of the filter list with the addition of -menu. An empty string returns the provider prefix. The Filter wrapper, Checkbox, Pagination, Button and Input independently inherit a common namespace. Changing names preserves the opened line, editor, selection, page and draft of the opened filter; CSS variables are set separately.
CSS table prefixes
General and local prefixCls, separate dropdownPrefixCls, RTL and CSS variables. The expanded line editor, selection, filters and pagination are preserved when changing names.
Prefix.svelte<script lang="ts"> import { Button, Checkbox, ConfigProvider, Input, Table, type TableColumn, type TableFilters, type TableKey, type TableSorter } from '@woodger/antd'; import { filterColumns, members, type Member } from './data'; let custom = $state(true); let local = $state(true); let localMenu = $state(true); let rtl = $state(false); let withVariables = $state(false); let selected = $state<TableKey[]>([1]); let expanded = $state<TableKey[]>([1]); let sorter = $state<TableSorter | null>(null); let filters = $state<TableFilters>({}); let current = $state(1); let events = $state<string[]>([]); let notes = $state<Record<string, string>>(Object.fromEntries( members.map(record => [String(record.key), `Note: ${record.name}`]) )); let submitted = $state('—'); const prefix = $derived(custom ? 'suite' : 'ant'); const tablePrefix = $derived(local ? 'project-grid' : ''); const menuPrefix = $derived(localMenu ? 'project-filters' : ''); const columns: TableColumn<Member>[] = filterColumns.map(column => ({ ...column, width: column.key === 'team' ? 420 : 160, fixed: column.key === 'name' ? 'start' : undefined })); </script> <style> .example, form, .editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; } .controls { display: flex; flex-wrap: wrap; gap: 12px; } .editor { gap: 8px; } p { margin: 0; } output { overflow-wrap: anywhere; } </style> {#snippet details(record: Member)} <div class="editor"> <label for={`table-prefix-note-${record.key}`} >{("Participant's note ")}{record.name}</label> <Input id={`table-prefix-note-${record.key}`} name={`note-${record.key}`} aria-label={("Draft line " + String((record.name)) + "")} bind:value={notes[String( record.key )]} /> </div> {/snippet} <div class="example"> <div class="controls"> <Checkbox bind:checked={custom}>{("General prefix Table suite")}</Checkbox> <Checkbox bind:checked={local}>{("Local prefix Table")}</Checkbox> <Checkbox bind:checked={localMenu}>{("Local menu prefix Table")}</Checkbox> <Checkbox bind:checked={rtl}>{("RTL Table with prefix")}</Checkbox> <Checkbox bind:checked={withVariables}>CSS variables Table</Checkbox> </div> <ConfigProvider prefixCls={prefix} direction={rtl ? 'rtl' : 'ltr'} theme={withVariables ? { cssVar: { prefix: 'table-theme' } } : undefined}> <form aria-label={("Table form with prefix")} onsubmit={event => { event.preventDefault(); submitted = Array.from(new FormData(event.currentTarget), ([name, value]) => `${name}: ${value}`).join('; ') || '—'; }}> <Table prefixCls={tablePrefix} dropdownPrefixCls={menuPrefix} class="prefix-table-main" dataSource={(members)} columns={(columns)} caption={("Table with CSS prefix")} bind:selectedRowKeys={selected} bind:sorter bind:filters bind:current rowSelection={{ fixed: true, getCheckboxProps: record => ({ 'aria-label': `Select participant with prefix ${record.name}` }) }} expandable={{ expandedRowRender: details, expandedRowKeys: expanded, fixed: true, onExpandedRowsChange: keys => { expanded = keys; events.push('expand'); } }} defaultPageSize={3} pagination={({ showSizeChanger: false })} scroll={{ x: 900, y: 240 }} onChange={change => { events.push(change.action); }} onSelectionChange={() => { events.push('selection'); }} /> <div><Button htmlType="submit">{("Read FormData Table")}</Button></div> <output aria-label={("FormData Table with prefix")}>{submitted}</output> </form> </ConfigProvider> <output aria-label={("Table state with prefix")}>{("\n Page: ")}{current}{("; selected: ")}{(selected .join(', ') || '—')}{("; revealed: ")}{(expanded.join(', ') || '—')} </output> <output aria-label={("Table events with prefix")}>{(events.join(' | ') || ("No events"))}</output> <output aria-label={("CSS prefix Table")}> Table: {(tablePrefix || prefix + '-table')}{("; filter list: ")}{(menuPrefix || prefix + '-dropdown')}-menu </output> <p> {("Local prefixCls specifies the full name of the Table, dropdownPrefixCls specifies the base name of the filter list with the addition of -menu. An empty string returns the provider prefix. The Filter wrapper, Checkbox, Pagination, Button and Input independently inherit a common namespace. Changing names preserves the opened line, editor, selection, page and draft of the opened filter; CSS variables are set separately.")} </p> </div>data.tsimport type { TableColumn } from '@woodger/antd'; export interface Member { key: number; name: string; team: string; tasks: number; active: boolean; } export const members: Member[] = [ { key: 1, name: "Anna", team: "Development", tasks: 18, active: true }, { key: 2, name: "Boris", team: "Design", tasks: 9, active: true }, { key: 3, name: "Vera", team: "Support", tasks: 0, active: false }, { key: 4, name: "Gleb", team: "Development", tasks: 24, active: true }, { key: 5, name: "Daria", team: "Design", tasks: 12, active: true }, { key: 6, name: "Egor", team: "Support", tasks: 15, active: true } ]; export const columns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name' }, { key: 'team', title: "Team", dataIndex: 'team' }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right' } ]; export const filterColumns: TableColumn<Member>[] = [ { key: 'name', title: "Name", dataIndex: 'name', sorter: (a, b) => a.name.localeCompare( b.name, 'ru' ) }, { key: 'team', title: "Team", dataIndex: 'team', filters: ["Development", "Design", "Support"].map(team => ({ text: team, value: team })), onFilter: (value, row) => row.team === value }, { key: 'tasks', title: "Tasks", dataIndex: 'tasks', align: 'right', sorter: ( a, b ) => a.tasks - b.tasks } ];
API
The examples use Ant Design 6.6.8 as a reference and the public @woodger/antd API.
| Theme | Example or limitation |
|---|---|
| Basic Usage | Typed columns, dataSource and rowKey. |
| JSX style API | Table.Column and Table.ColumnGroup declare columns and groups inside the table. |
| selection | Select one or more participants with Radio and Checkbox. |
| Selection and operation | Owner action on selectedRowKeys. |
| Custom selection | Commands to select all records, invert the current page, or clear the selection. |
| Filter and sorter | Comparator and flat filter list. |
| Filter in Tree | A filter with expandable groups of options. |
| Filter search | Find options with filterSearch. |
| Multiple sorter | Sort by team, then by task count. |
| Reset filters and sorters | The condition belongs to the owner. |
| Customized filter panel | Panel snippet with a numeric threshold and custom icon. |
| Ajax | mode=server with total; local source demonstrates request, cancellation, error and retry. |
| size | small/medium/large; inheritance componentSize. |
| border, title and footer | bordered, caption and title/footer snippets with current page data. |
| Expandable Row | expandedRowRender and rowExpandable. |
| Expand all rows | The example controls expansion in the app. Use defaultExpandAllRows to expand rows initially. |
| Order Specific Column | Table.EXPAND_COLUMN and Table.SELECTION_COLUMN set the column order. |
| colSpan and rowSpan | Header and data cells can span multiple rows or columns. |
| Tree data | Rows nested through children, with linked selection. |
| Fixed Header | The title is fixed inside scroll.y. |
| Auto height | There is no automatic calculation of window height. |
| Fixed Columns | fixed true/start/end, numeric width and horizontal scrolling. |
| Stack Fixed Columns | Sequential consolidation is not transferred. |
| Fixed Columns and Header | Collaboration between scroll.x/y and fixed. |
| Hidden Columns | column.hidden removes cells from the DOM while maintaining column sorting and filters. |
| Grouping table head | Child columns in children form a multi-level header. |
| Editable Cells | Snippet and InputNumber, the editing state belongs to the example. |
| Editable Rows | Shows owner save; onRow/components and there is no built-in editable row. |
| Nested tables | Table composition inside expandedRowRender. |
| Drag sorting | Drag-and-drop lines are not built in. |
| Drag Column sorting | No drag-and-drop speakers. |
| Drag sorting with handler | No handler/components for drag-and-drop. |
| ellipsis column | Truncates text in a column of a set width. |
| Shared column props | Shared width and alignment through the column prop. |
| ellipsis column custom tooltip | Built-in truncation with a Tooltip showing the full text. |
| Custom empty | Empty snippet and RenderEmpty from ConfigProvider. |
| Summary | Table.Summary renders totals for the current page. |
| Virtual list | Renders a window of rows. Jump to a record with scrollTo. |
| Responsive | The responsive option controls column visibility at different viewport widths. |
| Pagination Settings | Place pagination above and below the table with pagination.placement. |
| Fixed header and scroll bar with the page | The sticky option pins the header and scrollbar within the chosen region. |
| Dynamic Settings | Available size/border settings plus separate loading, scroll, selection examples. |
| Custom semantic dom styling | Header classes and cell styles with classNames and styles. |
| Custom body | Custom body linked to the header and scrollTo. |
| Conditional cell updates | Editor with content updates controlled by shouldCellUpdate. |
Table
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | The fully qualified local name of the Table, including wrapper, rows, cells, and filter elements. The empty string/undefined select ConfigProvider. Nested controls retain an independent common prefix. | string | General prefix + -table |
dropdownPrefixCls | Filter list base name: -menu is added. Does not change the common shell prefix of popup, Checkbox and Button; empty string/undefined return generic prefix. | string | General prefix + -dropdown |
dataSource | Table records. An empty array represents a known empty result. | readonly Row[] | null | — |
columns | Array of columns and groups. When provided, columns takes precedence over nested declarations. | readonly TableColumnInput<Row>[] | — |
column | Fills in omitted properties on columns and groups. | TableColumnDefaults<Row> | — |
getPopupContainer | Container for filters and the selection commands menu. | (trigger: HTMLElement) => HTMLElement | From ConfigProvider |
rowKey | Record field or function that returns a stable, unique key. | keyof Row | (record) => string | number | ConfigProvider.table.rowKey / key |
mode | In server, local filtering, sorting and slice are disabled. | client | server | client |
total | Total number of server records; in client it is calculated after filters. | number | dataSource.length in server |
sorter | bind:sorter, one sort. | TableSorter | null | local state |
defaultSorter | Initial sorting. | TableSorter | null | null |
sortDirections | Order in which sort directions cycle. | readonly (TableSortOrder | null)[] | ascend, descend |
showSorterTooltip | Tooltip for the next action on the header or sorter icon. | boolean | TableSorterTooltipProps | true |
filters | bind:filters; column key → array of selected values. | TableFilters | local state |
defaultFilters | Initial filters. | Readonly<Record<string, readonly TableFilterValue[]>> | {} |
current | bind:current - page from one. | number | local state |
defaultCurrent | Home page. | number | 1 |
pageSize | bind:pageSize — page size. | number | local state |
defaultPageSize | Initial number of rows. | number | 10 |
pagination | Pagination options, including placement for one or two pagers. | false | TablePaginationConfig | included |
rowSelection | Checkbox for selecting and setting up disabled entries. | boolean | TableRowSelection<Row> | false |
selectedRowKeys | bind:selectedRowKeys; the state is removed from rowSelection. | TableKey[] | local state |
defaultSelectedRowKeys | Initial choice. | readonly TableKey[] | [] |
onSelectionChange | Returns keys and selected records from dataSource, including descendants in collapsed branches. | (keys, rows, {type: single | all}) => void | — |
onChange | Filters, sorting, and pagination in one TableChange object. | (change: TableChange<Row>) => void | — |
expandable | Options for expanding child records and details rows. | TableExpandable<Row> | — |
loading | Loading state and Spin settings, including delay and description. | boolean | SpinProps | false |
locale | Local labels for filters, actions, and the empty state. | TableLocaleOverrides | From ConfigProvider |
tableLayout | Column width algorithm for a standard table. | 'auto' | 'fixed' | automatically |
components | Custom row and cell elements or a separate scrollable body. | TableComponents<Row> | — |
classNames | Classes for named table elements. | TableSemantic<Row, TableClassNameSlots> | — |
styles | CSS declarations for named table elements. | TableSemantic<Row> | — |
rootClassName | Additional class for the root and filter panels. | string | — |
disabled | Disable selection, sorting, filters and pagination. | boolean | ConfigProvider.componentDisabled |
bordered | Cell boundaries. | boolean | false |
size | Row size; medium adds the suffix -medium to the allowed Table prefix. | small | medium | large | ConfigProvider.componentSize |
caption | Native table label, separate from the visual title/footer. | RenderEmptyContent | — |
title | Panel above the table. Gets the sorted and filtered records of the current page; in server - the passed dataSource. | Snippet<[readonly Row[]]> | — |
footer | Panel under the table with the same records of the current page; not summary and not tfoot. | Snippet<[readonly Row[]]> | — |
showHeader | Show thead; hiding saves caption, rows and sort/filter state. | boolean | true |
rowClassName | Row class. Index is the position among visible rows on the page. Indent is the nesting level. | string | (record, index, indent) => string | — |
onRow | Row attributes and events. The index is relative to the expanded page. | (record, index) => TableRowProps | void | — |
onHeaderRow | Header row attributes and events. The index is the header level. | (columns, index) => TableRowProps | void | — |
rowHoverable | Hover highlight; does not disable selection, focus, and row actions. | boolean | true |
empty | Content when there are no entries and loading=false. | Snippet | RenderEmpty / Empty |
scroll | Scroll dimensions and position reset after actions. | TableScrollOptions | ConfigProvider.table.scroll |
virtual | Limits the rendered rows when scroll.y specifies a height. | boolean | false |
onScroll | Scroll event for the region. In virtual mode it reports vertical scrolling. | (event: Event & { currentTarget: HTMLDivElement }) => void | — |
nativeElement | Root DOM element through bind:nativeElement. | HTMLDivElement | — |
sticky | Pins the header and horizontal scrollbar. | boolean | TableSticky | false |
summary | Totals for the current page, optionally pinned to the top or bottom. | Snippet<[data: readonly Row[]]> | TableSummaryConfig<Row> | — |
id | Passed to the inner table container alongside data-* attributes. | string | — |
role | Applied to the table element along with aria-* attributes. | HTMLTableAttributes["role"] | — |
aria-label | Available table name without caption. | string | caption / locale |
class | External wrapper class. | string | — |
style | CSS external wrapper. | string | — |
TableColumnInput
| Property | Description | Type | Default |
|---|---|---|---|
children | Columns with a shared group header. | readonly TableColumnInput<Row>[] | — |
responsive | Grid breakpoints at which a top-level column is visible. | readonly GridBreakpoint[] | — |
colSpan | Number of columns spanned by the header cell. Zero hides the cell. | number | — |
rowSpan | Number of rows spanned by the header cell. Zero hides the cell. | number | — |
onCell | Cell attributes and spans. The index is relative to the expanded page. | (record, index) => TableCellProps | void | — |
onHeaderCell | Header cell attributes. Can override the column's colSpan and rowSpan. | (column) => TableCellProps | void | — |
hidden | Hide a column from the DOM without removing its sorting and filters. fixed offsets only take into account visible columns. | boolean | false |
className | Class of header and column cells. | string | — |
rowScope | Makes data cells real th with the specified scope. | row | rowgroup | — |
key | An omitted key comes from dataIndex or position. Filtering and sorting use a string key. | string | number | dataIndex / position |
title | Text, a number, an array or a snippet receiving the current filters and sorting. | TableColumnTitle<Row> | — |
dataIndex | Record key or path to a nested value. | TableDataIndex<Row> | — |
render | Receives the record, index among siblings, and original value. | Snippet<[record: Row, index: number, value?: unknown]> | dataIndex value |
shouldCellUpdate | Decides whether to accept a new record for the cell content. | (record: Row, previousRecord: Row) => boolean | — |
sorter | Comparator, object with a multiple priority, or server sort criterion. | boolean | TableSortCompare<Row> | TableColumnSorter<Row> | — |
sortOrder | Sort direction controlled by the app. null clears the criterion. | TableSortOrder | null | — |
defaultSortOrder | Initial column sort direction. | TableSortOrder | null | — |
sortDirections | Column-specific cycle of sort directions. | readonly (TableSortOrder | null)[] | From Table |
sortIcon | Custom sort icon with the current direction. | Snippet<[{ sortOrder: TableSortOrder | null }]> | — |
showSorterTooltip | Sorter tooltip settings for an individual column. | boolean | TableSorterTooltipProps | From Table |
filters | Filter options with optional child options. | readonly TableFilterOption[] | — |
filterMode | Menu or tree of options. | 'menu' | 'tree' | menu |
filterSearch | Search by label or use an app-provided predicate. | TableFilterSearch | false |
filtered | Highlights the filter independently of its selected values. | boolean | false |
filteredValue | Applied column values controlled by the app. | readonly TableFilterValue[] | null | — |
defaultFilteredValue | Initial filter values for the column. | readonly TableFilterValue[] | null | — |
filterResetToDefaultFilteredValue | Reset restores the initial values in the draft. | boolean | false |
filterDropdown | Custom filter panel with draft values and actions. | RenderEmptyContent | Snippet<[info: TableFilterDropdownProps]> | — |
filterDropdownProps | onOpenChange(open) reports requests to open or close the panel. Selecting an item updates the filter draft and keeps the panel open. | TableFilterDropdownOptions | — |
filterOnClose | Applies the built-in filter draft when the user closes the panel. | boolean | false |
filterIcon | Custom filter icon with an active state. | RenderEmptyContent | Snippet<[filtered: boolean]> | — |
onFilter | Local check of one record. | (value, record) => boolean | — |
filterMultiple | Allow multiple filter values. | boolean | true |
align | Aligns cell text. | TableAlign | CSS |
width | Width col; numbers in px. | number | string | automatically |
minWidth | Minimum width in pixels with auto layout and in the virtual window. | number | — |
ellipsis | Truncates text. showTitle controls the cell's native tooltip. | boolean | { showTitle?: boolean } | false |
fixed | sticky column; true means start. If docked columns do not fit, docking is disabled. | boolean | start | end | false |
TableRowSelection
| Property | Description | Type | Default |
|---|---|---|---|
type | Select multiple rows or a single row. | 'checkbox' | 'radio' | checkbox |
selectedRowKeys | Controlled keys. Take precedence over the Table prop with the same name. | readonly TableKey[] | local state |
defaultSelectedRowKeys | Initial choice. | readonly TableKey[] | [] |
onChange | New keys, known records, and the selection method. | (keys, rows, { type: TableRowSelectMethod }) => void | — |
onSelect | Single-row action. Called before onChange. | (record, checked, rows, event) => void | — |
preserveSelectedRowKeys | Keeps keys and remembers the selected records when dataSource changes. | boolean | false |
selections | Checkbox selection menu with built-in or custom commands. | boolean | readonly (TableSelectionItem | TableSelectionPreset)[] | false |
hideSelectAll | Hide the header checkbox and selection menu. | boolean | false |
getTitleCheckboxProps | Attributes and events for the header checkbox. | () => TableSelectionControlProps | — |
columnTitle | Selection header content. The snippet receives the original checkbox. | RenderEmptyContent | Snippet<[checkbox: Snippet | undefined]> | — |
renderCell | Selection cell content. Use origin to render the built-in control. | Snippet<[checked, record, index, origin]> | — |
onCell | Selection cell attributes and spans. | (record, index) => TableCellProps | void | — |
checkStrictly | Set to false to link selection between parents and descendants. | boolean | true |
fixed | Pin the selection column to a logical edge. | TableFixed | false |
columnWidth | Width of the selection column. | number | string | selectionColumnWidth |
align | Alignment of the selection column content. | TableAlign | — |
getCheckboxProps | Attributes of the row selection control, including disabled and aria-label. | (record) => TableSelectionControlProps | — |
TableExpandable
| Property | Description | Type | Default |
|---|---|---|---|
expandedRowRender | Content for a separate details row, which can contain a nested Table. | Snippet<[record: Row, index: number, indent: number, expanded: boolean]> | — |
forceRender | Keeps details content when the row collapses. | boolean | false |
expandedRowClassName | Classes for the details row and child rows. | string | (record, index, indent) => string | — |
expandIcon | Custom toggle with the expansion state and the original button in origin. | Snippet<[info: TableExpandIconInfo<Row>, origin: Snippet]> | — |
expandedRowKeys | Managed keys are expandable inside. The owner accepts the new array in onExpandedRowsChange. | readonly TableKey[] | local state |
defaultExpandedRowKeys | Initially disclosed records. Read once; a subsequent change does not reset the state. | readonly TableKey[] | [] |
defaultExpandAllRows | Expands branches on the initial page when defaultExpandedRowKeys is unset. | boolean | false |
childrenColumnName | Name of the field containing child records. | string | children |
indentSize | Indentation per nesting level in pixels. | number | 15 |
expandRowByClick | Toggles expansion when a row is clicked. | boolean | false |
showExpandColumn | Shows the details column or the expansion buttons in a tree. | boolean | true |
onExpand | Request to expand one row; called before onExpandedRowsChange. | (expanded, record) => void | — |
onExpandedRowsChange | Complete new set of keys, including other pages. For managed state, update expandable.expandedRowKeys. | (keys: TableKey[]) => void | — |
rowExpandable | Which records have details available. | (record) => boolean | true |
columnTitle | Name of the service column. | RenderEmptyContent | empty header |
columnWidth | Width of the disclosure column. | number | string | 48px |
fixed | Pin the expansion column to a logical edge. | TableFixed | false |
TableRef
| Property | Description | Type | Default |
|---|---|---|---|
scrollTo | Scroll to a position or to a row on the current page by key or index. | (config: TableScrollConfig) => void | — |
TableScrollOptions
| Property | Description | Type | Default |
|---|---|---|---|
x | Table width. true sizes it to the content. | number | string | true | — |
y | Scroll region height. In virtual mode, use a number of pixels. | number | string | — |
scrollToFirstRowOnChange | Scroll to the start after the user sorts, filters, or changes pages. | boolean | virtual |
TablePaginationConfig
| Property | Description | Type | Default |
|---|---|---|---|
placement | Alignment above and below the table. An empty array hides the controls. | readonly TablePaginationPlacement[] | bottomEnd |
TableSticky
| Property | Description | Type | Default |
|---|---|---|---|
offsetHeader | Top offset of the header in pixels. | number | 0 |
offsetSummary | Bottom offset of the totals in pixels. | number | 0 |
offsetScroll | Bottom offset of the additional scrollbar in pixels. | number | 0 |
getContainer | Returns the scroll region. Defaults to the table's window. | () => HTMLElement | Window | null | undefined | — |
TableChange
| Property | Description | Type | Default |
|---|---|---|---|
action | Reason for change. | sort | paginate | filter | — |
pagination | Current page and size. | {current, pageSize, total} | — |
sorter | First active sort criterion. | TableSorter | null | — |
sorters | All active criteria when sorting by multiple columns. | TableSorter[] | — |
filters | Values by column keys when the table has filters. | TableFilters | undefined | — |
currentDataSource | Root rows with their child records. In client mode, this is the result after sorting and filtering, before pagination. | Row[] | — |
TableSorter
| Property | Description | Type | Default |
|---|---|---|---|
columnKey | key of the sortable column. | string | is required |
order | Direction; null total sorter means no sorting. | ascend | descend | is required |
TableFilterOption
| Property | Description | Type | Default |
|---|---|---|---|
text | Variant label. | RenderEmptyContent | is required |
value | Value in filters and onFilter. | string | number | boolean | is required |
children | Options within a filter group. | readonly TableFilterOption[] | — |
The onChange handler receives a TableChange object. The render snippet receives the record, index, and original value. Define column groups with children in columns.
Semantic DOM
Use classNames and styles to style named elements. Provider and table settings are merged for each element.
The classes below are shown for a standard ant-table. prefixCls replaces this part of the names; marker ant-table-css-var is saved. Checkbox, Button and Pagination independently use a common provider prefix; pagination additionally gets the Table owner class with -pagination. dropdownPrefixCls only changes the name of the list inside the filter, with the suffix -menu.
| Element | Purpose |
|---|---|
.ant-table-wrapper | Root class/style and RTL direction. |
.ant-table-content | Focusable role=region with internal scrolling. |
table / caption | Native table structure and accessible name. |
.ant-table-thead | Header th elements with scope=col or colgroup and aria-sort. |
.ant-table-column-sorters | Sort button accessible from the keyboard. |
.ant-table-tbody | Data lines. |
.ant-table-selection-column | Header checkbox and commands, plus Checkbox or Radio in data rows. |
tfoot | Table.Summary rows. |
.ant-table-sticky-scroll | Additional horizontal scrollbar. |
.ant-table-row-expand-icon | Expand button with aria-expanded/aria-controls. |
.ant-table-expanded-row | Details line. |
.ant-table-placeholder | Contents empty when there are no records. |
.ant-table-title / .ant-table-footer | Visual panels with the current page. |
th[scope=row] / th[scope=rowgroup] | Row headers specified by column.rowScope. |
.ant-table-pagination | Separate navigation Pagination. |
| Element | Purpose |
|---|---|
root | Outer container. |
section | Container around the scrollable region. |
content | Scroll region of a standard table without a fixed header. |
title / footer | Panels above and below the table. |
header.wrapper / header.row / header.cell | Header wrapper, rows, and cells. |
body.wrapper / body.row / body.cell | Body wrapper, data rows, and cells. |
pagination.root / pagination.item | Pagination container and items. |
Registration tokens
Set table styles with theme.components.Table. Design tokens control dimensions, backgrounds, borders, filters, and the sticky scrollbar.
| Token | Purpose |
|---|---|
headerBg | Header background. |
headerColor | Header text. |
headerSortActiveBg | Sortable header background. |
headerSortHoverBg | Hover sortable header. |
bodySortBg | Background of the sorted column. |
rowHoverBg | Hover lines. |
rowSelectedBg | Selected row. |
rowSelectedHoverBg | Hover the selected row. |
rowExpandedBg | Details background. |
cellPaddingBlock | Vertical padding large. |
cellPaddingInline | Horizontal padding large. |
cellPaddingBlockMD | Vertical padding medium. |
cellPaddingInlineMD | Horizontal padding medium. |
cellPaddingBlockSM | Vertical padding small. |
cellPaddingInlineSM | Horizontal padding small. |
borderColor | Border color. |
headerBorderRadius | Cap radius. |
footerBg | footer panel background. |
footerColor | footer panel text. |
cellFontSize | Font large. |
cellFontSizeMD | Font medium. |
cellFontSizeSM | Font small. |
headerSplitColor | Header separator. |
fixedHeaderSortActiveBg | Sorting of the sticky header. |
headerFilterHoverBg | Hover filter. |
filterDropdownMenuBg | Filter menu background. |
filterDropdownBg | Filter panel background. |
expandIconBg | Reveal background. |
selectionColumnWidth | Width of the checkbox column. |
stickyScrollBarBg | Sticky scrollbar background. |
stickyScrollBarBorderRadius | Sticky scrollbar corner radius. |
expandIconMarginTop | Top opening margin. |
expandIconHalfInner | Geometry of the disclosure icon. |
expandIconSize | Opening size. |
expandIconScale | Disclosure scale. |
headerIconColor | Header icons. |
headerIconHoverColor | Hover header icons. |
| Token | Meaning |
|---|---|
colorBgContainer | #ffffff |
colorText | rgba(0,0,0,0.88) |
colorTextHeading | rgba(0,0,0,0.88) |
colorPrimary | #2f54eb |
colorBorderSecondary | #f0f0f0 |
fontSize | 14 |
lineHeight | 1.5714285714285714 |
paddingSM | 12 |
FAQ
Why is rowKey actually required?
Without an explicit rowKey, record.key is read. Unique keys link selection, expansion, and the DOM; The index of the visible row is not suitable.
How does server mode work?
The application processes TableChange and passes the finished page, total and loading. Table does not load data.
Why can't the React onChange example be literally copied?
Svelte receives one TableChange object. The sort, filter, page, and selection states are on the Table; render columns receive record/index, expansion is controlled via expandable.
What does selecting all rows do?
The header checkbox selects available rows on the current page and preserves keys on other pages. The menu's Select all command applies to the entire filtered data set.
Why does the filter return to the first page?
After the filter, the previous page may be missing. Managed state allows the application to negotiate the page and the overall total.
How to add editing and hide columns?
Use render snippet and update dataSource for editing, column.hidden for hiding. The examples preserve stable row keys.
How does the theme affect pagination size?
A medium table uses small pagination by default. In the prefix example, page items are 24 px tall in the regular theme and 21 px in the compact theme. Changing the prefix within the same theme preserves the height of the items and the table.