Components/DataTable
Since 1.0.0BETA

DataTable

Lightweight data table with sorting and selection

This page was migrated by AI, please review carefully

Migration is complete, but please validate against source code and manual review.

DataTable

Lightweight data table with sorting, row selection, and custom rendering.

Basic Usage

Demo will load when visible.
<script setup lang="ts">
const columns = [
  { key: 'name', title: 'Name' },
  { key: 'role', title: 'Role' },
  { key: 'score', title: 'Score', sortable: true },
]

const data = [
  { id: 1, name: 'Ava', role: 'Designer', score: 92 },
  { id: 2, name: 'Noah', role: 'Engineer', score: 88 },
  { id: 3, name: 'Mia', role: 'PM', score: 95 },
]
</script>

<template>
  <TxDataTable :columns="columns" :data="data" striped bordered />
</template>

Row Selection

Demo will load when visible.
<script setup lang="ts">
import { ref } from 'vue'

const selectedKeys = ref([])
</script>

<template>
  <TxDataTable
    v-model:selected-keys="selectedKeys"
    :columns="columns"
    :data="data"
    row-key="id"
    selectable
  />
</template>

Sorting Interaction

Sortable headers expose aria-sort and support pointer click, Enter, and Space to cycle through ascending, descending, and unsorted states. When sortOnClient=false, the table still emits sortChange without reordering local rows.

API

TxDataTable Props

NameTypeDefaultDescription
columnsDataTableColumn[][]Column config
dataany[][]Data source
rowKeystring | (row, index) => string | numberindexUnique row key
loadingbooleanfalseLoading state
emptyTextstring'No data'Empty text
stripedbooleanfalseZebra rows
borderedbooleanfalseShow borders
hoverbooleantrueHover highlight
selectablebooleanfalseSelectable rows
selectedKeysArray<string | number>[]Selected keys
defaultSort{ key: string; order: 'asc' | 'desc' | null }nullDefault sort
sortOnClientbooleantrueClient-side sort

DataTableColumn

FieldTypeDescription
keystringColumn key
titlestringHeader title
dataIndexstringData field
widthstring | numberColumn width
align'left' | 'center' | 'right'Alignment
sortablebooleanSortable
sorter(a, b) => numberCustom sorter
format(value, row, index) => stringCell formatter
headerClassstringHeader class
cellClassstringCell class

Events

EventPayloadDescription
update:selectedKeys(keys)Selection update
selectionChange(keys)Selection change
sortChange(sort)Sort change
rowClick({ row, index })Row click

Slots

NameDescription
header-<columnKey>Custom header
cell-<columnKey>Custom cell
emptyEmpty slot