Component

Table

安装 Installation

npx timkit add table --yes --framework react

用法 Usage

import { Table } from "@/components/ui/table"

className 与 variant、size 可以一起用。字段以 timkit agent inspect table --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

20 / 20

Table · Interactive State · 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

table

Logic

none

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
noneState and interaction provider used by this component.
logic.machine
string
-Underlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/coreRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
-Dependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
sortColumn
string
-Column id currently used for sorting.
sortDirection
enum (asc | desc)
-Sort direction for sortColumn.
selectedIds
array
-Selected row ids.
emptyLabel
string
No resultsText shown when the table has no rows.

Events

PropTypeDefaultDescription
onSortChange
event
-Called when a column sort changes.
onSelectionChange
event
-Called when row selection changes.

TypeScript

来自 TypeScript 导出。

PropTypeDefaultDescription
striped
boolean
-When `true`, applies a striped pattern style.
hoverable
boolean
-When `true`, applies visual styles on user hover.

Slots

PropTypeDefaultDescription
default
slot
-The table segments

Parts

PropTypeDefaultDescription
root*
root
-The table container
header
part
-The table header (thead)
body
part
-The table body (tbody)
footer
part
-The table footer (tfoot)
row
part
-A table row (tr)
head
part
-A table header cell (th)
cell
part
-A table body cell (td)
caption
part
-The table caption
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • ArrowDown and ArrowUp move the active row.
  • Home moves to the first row.
  • End moves to the last.
  • Space selects that row.
  • Enter or Space on a column header sorts that column.
  • The sort status names the sorted column and whether the order is ascending or descending.
  • The selection status reads how many rows are selected.
  • Space on Select all rows selects every visible row.
  • A filter keeps rows whose cells contain the query and ignores case.
  • An empty filter shows every row.
  • A filter that matches nothing shows the empty label.
  • A filter that matches rows announces how many rows match.
  • The filter is named Filter rows.
  • When pageSize is set, Previous page and Next page move between pages of that size.
  • The page status reads the current page and the page count.
  • Select all and the row keys use the visible page.
  • Changing the filter returns to the first page.
  • A row with a detail has an Expand button.
  • Activating it shows the detail and names the button Collapse.
  • Activating it again hides the detail.
  • A disabled table ignores those keys, the filter, the page buttons, and the detail button.
  • Sort headers and row checkboxes are in the tab order unless the table is disabled.
  • The active row is in the tab order unless the table is disabled.
  • The caption names the table.
  • An omitted caption leaves the table unnamed.
  • On the mini program, the select-all control, each row selection, and the detail button sit in cells.
  • The empty label sits in a row.
  • An open detail sits in a cell.
  • In static HTML, a caption named Table names the table.
  • The basic table is named People.
  • On the mini program, aria-controls is set only while the row detail is open.

行为契约

Contract

props、默认值和运行时状态。

  • Sorting a column cycles ascending, descending, then off.
  • Rows can be selected one by one or all at once.
  • An empty table shows the empty label.
  • A disabled table ignores the filter, the page buttons, and the detail button.