DataTable
Table + sort/search/select/paginate
Rows people sort, search, page through and pick from: an admin list, an order history. For a small table that just shows data, use Table. For cards instead of rows, DataView.
Everything runs in the browser by default. Hand it the full array and it sorts, filters and slices. For large sets switch to server mode below and the table becomes a thin view over one page at a time. When rows nest, TreeTable.
| Status | |||||
|---|---|---|---|---|---|
| 1 | 第1話 プロローグ | 2017-04-01 | 1,200 | aired | |
| 2 | 第2話 運命の出会い | 2017-04-02 | 1,658 | aired | |
| 3 | 第3話 フラグの立たない | 2017-04-03 | 1,729 | aired | |
| 4 | 第4話 冴えない彼女 | 2017-04-04 | 1,382 | aired | |
| 5 | 第5話 同人誌 | 2017-04-05 | 970 | aired |
| Order | City | Items | Shipped | Carrier | Total | |||
|---|---|---|---|---|---|---|---|---|
| A-1040 | Megumi Kato | Tokyo | 1 | 2026-10-01 | 2026-10-03 | Yamato | $18.50 | |
| A-1041 | Eriri Spencer | Osaka | 2 | 2026-10-02 | 2026-10-04 | JNE | $37.00 | |
| A-1042 | Utaha Kasumigaoka | Bandung | 3 | 2026-10-03 | 2026-10-05 | Yamato | $55.50 | |
| A-1043 | Michiru Hyodo | Surabaya | 4 | 2026-10-04 | 2026-10-06 | JNE | $74.00 | |
| A-1044 | Megumi Kato | Kyoto | 1 | 2026-10-05 | 2026-10-07 | Yamato | $18.50 | |
| A-1045 | Eriri Spencer | Tokyo | 2 | 2026-10-06 | 2026-10-08 | JNE | $37.00 | |
| A-1046 | Utaha Kasumigaoka | Osaka | 3 | 2026-10-07 | 2026-10-09 | Yamato | $55.50 | |
| A-1047 | Michiru Hyodo | Bandung | 4 | 2026-10-08 | 2026-10-10 | JNE | $74.00 |
Pinned and resizable columns. A wide table scrolls sideways. pin: "start" or pin: "end" on a column keeps it in view while the rest scroll. Pinned columns move to their side. When a column is pinned to the start, the checkbox column is pinned too.
resizableputs a handle on the end edge of each header. Drag it, or focus it and press ← or → to change the width by 16px. The smallest width is 48px.resizable: falseon a column keeps that column at its width.- The first resize records the width of every column. After that, the table uses those widths exactly, and text that does not fit ends with "…".
v-model:widthsholds the widths in px by column key. Save it, and give it back on the next visit, to keep the layout.
| No rows. | ||
Server mode. Pass server and total. The rows you give are the current page, and every sort / search / page / page-size change emits state for you to fetch with. Nothing is sorted or sliced on the client.
- Client mode sorts, filters and pages
rowsitself. Withserver,rowsis one page: listen to@state(sort, query, page, page size) and fetch. Settotalandloadingwhile you do: the table is marked busy and dims. - Mark one column
header: true: its cells become row headers, and row checkboxes are named after them ("Select Megumi"). @rowClickis for pointer convenience only. Put a link or button in a cell for anything keyboard users must reach.- The row count is a status, so a search or page change is announced.
Usage
import { BlessDataTable } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
columns* | BlessDataColumn<T>[] | — | |
rows* | T[] | — | |
rowKey* | keyof T & string | — | |
pageSize | number | 10 | |
pageSizes | number[] | [10, 25, 50] | |
selectable | boolean | — | |
searchable | boolean | — | |
searchKeys | (keyof T & string)[] | — | |
searchPlaceholder | string | "Search…" | |
labels | Partial<{ search: string; selectPage: string; rowsPerPage: string; selectRow: (name: string) => string; resize: (column: string) => string; }> | — | names of the select-page checkbox and the page-size select |
emptyText | string | "No rows." | |
caption | string | — | |
server | boolean | — | rows are one server page; sort / query / page are yours to fetch with (see `state` event) |
total | number | — | server mode: total row count |
loading | boolean | — | |
resizable | boolean | — | drag the edge of a header, or focus it and press ←/→, to change a column's width |
widths | Record<string, number> | {} | column widths in px, set by resizing; bind it to keep them |
Events
| Name | Payload | Description |
|---|---|---|
state | [s: { sortKey: string | null; sortDir: "asc" | "desc"; query: string; page: number; pageSize: number; }] | |
update:selected | [rows: T[]] | |
rowClick | [row: T] | |
update:widths | [value: Record<string, number>] |
Slots
| Name | Scope | Description |
|---|---|---|
toolbar | { state: { sortKey: string | null; sortDir: "asc" | "desc"; page: number; pageSize: number; query: string; selected: Set<string | number> & Omit<Set<string | number>, keyof Set<any>>; hidden: Set<string> & Omit<Set<string>, keyof Set<any>>; }; selected: T[]; } |