Skip to content
Calm motion: animations on this site only fade, with no movement

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.

Basic
Episodes
Status
1第1話 プロローグ2017-04-011,200aired
2第2話 運命の出会い2017-04-021,658aired
3第3話 フラグの立たない2017-04-031,729aired
4第4話 冴えない彼女2017-04-041,382aired
5第5話 同人誌2017-04-05970aired
23 rows
Pinned and resizable columns
OrderCityItemsShippedCarrierTotal
A-1040Megumi KatoTokyo12026-10-012026-10-03Yamato$18.50
A-1041Eriri SpencerOsaka22026-10-022026-10-04JNE$37.00
A-1042Utaha KasumigaokaBandung32026-10-032026-10-05Yamato$55.50
A-1043Michiru HyodoSurabaya42026-10-042026-10-06JNE$74.00
A-1044Megumi KatoKyoto12026-10-052026-10-07Yamato$18.50
A-1045Eriri SpencerTokyo22026-10-062026-10-08JNE$37.00
A-1046Utaha KasumigaokaOsaka32026-10-072026-10-09Yamato$55.50
A-1047Michiru HyodoBandung42026-10-082026-10-10JNE$74.00
8 rows

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.

  • resizable puts 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: false on 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:widths holds the widths in px by column key. Save it, and give it back on the next visit, to keep the layout.
Server mode
Episodes (server-paged)
No rows.
0 rows
0 rows on the “server”, 0 in the DOM

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 rows itself. With server, rows is one page: listen to @state (sort, query, page, page size) and fetch. Set total and loading while 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").
  • @rowClick is 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 ​

ts
import { BlessDataTable } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
columns*BlessDataColumn<T>[]—
rows*T[]—
rowKey*keyof T & string—
pageSizenumber10
pageSizesnumber[][10, 25, 50]
selectableboolean—
searchableboolean—
searchKeys(keyof T & string)[]—
searchPlaceholderstring"Search…"
labelsPartial<{ 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
emptyTextstring"No rows."
captionstring—
serverboolean—rows are one server page; sort / query / page are yours to fetch with (see `state` event)
totalnumber—server mode: total row count
loadingboolean—
resizableboolean—drag the edge of a header, or focus it and press ←/→, to change a column's width
widthsRecord<string, number>{}column widths in px, set by resizing; bind it to keep them

Events

NamePayloadDescription
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

NameScopeDescription
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[]; }

Released under the MIT License. Character names and artwork belong to their owners.