Table

Table

Sortable data table with selectable rows.

Based on APG Table Pattern.

Demo

Name Email Role
Alice Johnsonalice@example.comAdmin
Bob Smithbob@example.comUser
Charlie Browncharlie@example.comUser
Diana Rossdiana@example.comEditor

Usage

@styled_table.table(
  id="users",
  columns=[
    table_column("name", "Name", sortable=true),
    table_column("email", "Email", sortable=true),
    table_column("role", "Role"),
  ],
  rows=[
    table_row("1", ["Alice", "alice@example.com", "Admin"]),
    table_row("2", ["Bob", "bob@example.com", "User"]),
  ],
  aria_label="User data",
  selectable=true,
)

Props

PropTypeDefaultDescription
idString-Table ID
columnsArray[TableColumn]-Column definitions
rowsArray[TableRow]-Row data
aria_labelString?NoneAccessible label
selectableBoolfalseEnable row selection
classString?NoneAdditional CSS class
onrowselect(String) -> Unit?NoneRow selection callback

BEM Classes

ClassDescription
.tableRoot wrapper (overflow container)
.table__tableThe actual table element
.table__headerTable header row
.table__thHeader cell
.table__th--sortableSortable header cell
.table__sort-iconSort direction indicator
.table__bodyTable body
.table__rowData row
.table__cellData cell

Data Attributes

AttributeDescription
aria-sortSort direction (ascending, descending, none)
data-selectedRow selection state (true, false)
data-row-idRow identifier

Features

  • Sortable columns: Click header to toggle sort direction

  • Row selection: Click row to select (when enabled)

  • Keyboard navigation: Tab through headers, Enter to sort

  • Responsive: Horizontal scroll on overflow

Accessibility

  • aria-sort on sortable headers

  • aria-label for table description

  • Proper scope="col" on header cells

  • Focus management for keyboard users