Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 11 Data

Data table

Rows of records the reader scans and compares: orders, users, payments. A real table, named by its caption, so screen readers announce the row and column of every cell. Sorting is announced too.

Use it in Angular
import {
  DataTableComponent,
  TableCellDirective,
Works with

Sorting, custom cells and pagination

Sort by customer, date or total. Status is a badge; totals line up on the last digit. The table only reports the sort: the page sorts and slices the rows, usually on the server.

Orders
Order Status
#1040 Hatem Mohamed 2026-11-18 85 EGP Paid
#1049 Mohamed Ibrahim 2026-11-18 418 EGP Late
#1058 Ibrahim Hatem 2026-11-18 751 EGP Paid
#1041 Mohamed Ibrahim 2026-11-17 222 EGP Preparing
#1050 Ibrahim Hatem 2026-11-17 555 EGP Paid
#1059 Hatem Ibrahim 2026-11-17 888 EGP Preparing
#1042 Ibrahim Hatem 2026-11-16 359 EGP Paid
#1051 Hatem Ibrahim 2026-11-16 692 EGP Cancelled
Angular
columns: TableColumn<Order>[] = [
  { key: 'id', header: 'Order', value: (o) => '#' + o.id },
  { key: 'customer', header: 'Customer', sortable: true },
  { key: 'placed', header: 'Placed', sortable: true },
  { key: 'total', header: 'Total', sortable: true, align: 'end', value: (o) => o.total + ' EGP' },
  { key: 'status', header: 'Status' },
];
sort = signal<TableSort | null>({ key: 'placed', direction: 'descending' });
page = signal(1);
// Load or sort the rows for sort() and page(), usually on the server.

<ui-card>
  <ui-data-table caption="Orders" [columns]="columns" [rows]="rows()" [(sort)]="sort" rowKey="id">
    <ng-template uiCell="status" let-order>
      <ui-badge [variant]="tone(order)">{{ order.status }}</ui-badge>
    </ng-template>
  </ui-data-table>
  <ui-pagination [(page)]="page" [total]="total()" [pageSize]="8" />
</ui-card>

Empty and loading

Say why the table is empty in words. While loading, the table is marked busy and screen readers hear the loading text once.

Orders today
Order Status
Loading
Angular
<ui-data-table
  caption="Orders today"
  [columns]="columns"
  [rows]="rows()"
  [loading]="loading()"
  loadingLabel="Loading orders"
  emptyMessage="No orders today yet."
/>

In Arabic

الطلبات
الطلب العميل الإجمالي
#1042 حاتم محمد ٣٤٠ جنيه
#1041 محمد إبراهيم ١٢٠ جنيه
#1040 إبراهيم حاتم ٨٥ جنيه
Angular
<ui-data-table caption="الطلبات" [columns]="columns" [rows]="orders" rowKey="id" />
<ui-pagination [(page)]="page" [total]="23" [pageSize]="8" [labels]="labels" />

labels = {
  nav: 'التنقل بين الصفحات',
  previous: 'الصفحة السابقة',
  next: 'الصفحة التالية',
  page: (n: number) => `صفحة ${n}`,
  summary: (first: number, last: number, total: number) => `${first}–${last} من ${total}`,
};

Page navigation has its own page: Pagination.

When to use something else

If you needUse
A few label and value pairsProperty list
Events in time orderTimeline
Nested items such as foldersTree

Inputs

NameTypeDefaultWhat it does
captionstring — Required. Names the table; screen readers announce it.
hideCaptionbooleanfalseKeep the caption for screen readers only, when a heading above already names the table.
columnsTableColumn<T>[] — Required. { key, header, sortable?, align?, value? } per column.
rowsT[] — Required. The rows of the current page.
sortTableSort | null (model) — Bind [(sort)]: { key, direction }. Sort the rows yourself.
rowKeykeyof T | (row) => unknown — What identifies a row, so rows keep their state across updates.
loading / loadingLabelboolean / stringfalse / 'Loading'Marks the table busy and reads the label once.
emptyMessagestring'No results' from labelsShown when there are no rows; pass the translated text.
ng-template uiCell="key"directive — A custom cell for that column; let-row gives the row.

Keyboard and screen readers

KeysWhat they do
Enter or Space On a column heading, sort by it.
  • A real table named by its caption, so the row and column of every cell are read.
  • The sorted column is marked, and the new order is announced.