Components
BaseDataTable
The data table of every list: search, filters, columns menu, grouping, selection, row and bulk actions and pagination.
Simple
Code | Product | Status | Price |
|---|---|---|---|
| PRD-001 | Linen shirt | Active | $59.00 |
| PRD-002 | Canvas tote | Draft | $24.00 |
| PRD-003 | Wool scarf | Archived | $39.00 |
Full featured
Search, filter by status or price, hide columns, group by category, select rows to see the bulk bar and open the row menu.
Code | Product | Category | Status | Price | ||
|---|---|---|---|---|---|---|
| PRD-001 | Linen shirt | Clothing | Active | $59.00 | ||
| PRD-002 | Canvas tote | Bags | Draft | $24.00 | ||
| PRD-003 | Wool scarf | Clothing | Archived | $39.00 | ||
| PRD-004 | Leather wallet | Bags | Active | $45.00 | ||
| PRD-005 | Cotton socks | Clothing | Active | $12.00 |
Loading
Invoice | Client | Amount |
|---|---|---|
Initial sort
Start a table sorted by binding v-model:sort-by to a ref: const sortBy = ref([{ key: 'issued', order: 'desc' }]). A plain :sort-by with an inline array is a controlled value without a listener, so the table goes back to it whenever the page renders again and clicking a header seems to do nothing.
<BaseDataTable v-model:sort-by="sortBy" :headers :items />
On phones
Below 600px a table cannot fit its columns, so every row becomes a compact two-line row. A table with mobile-layout (an object) or #mobile-row also switches to these rows at any width when its columns still do not fit after responsive-columns hid theirs: it measures the table once fonts are loaded and goes back to columns when the container is wide enough again, so tune responsive-columns to keep the full table on laptops and let the compact rows take over below. Compact rows keep the row actions menu at the end and hide the checkboxes: under show-select a Select button in the toolbar (an icon next to the search below 600px) or a long press on a row enters selection mode, where checkboxes labelled with row-label appear, tapping a row toggles it instead of opening it, and Cancel or clearing the last row leaves the mode. Pass mobile-layout to build it from the cells you already render: primary is the column that leads the row (usually the identity cell with avatar or icon, name and subtitle), value and status stack on the end side, and details adds a line of further cells separated by dots. Each one reuses its #item.<key> slot, or shows the plain value when the column has none. For anything else, write a #mobile-row slot with BaseDataTableMobileRow. mobile-layout="stack" keeps Vuetify's label and value pairs, for documents and reference tables; without any of the three, development logs a warning naming the table's columns.
The Data tables guide covers filters, actions, card grids through #body and the density preference.
API
Props
Name | Type | Default | Description |
|---|---|---|---|
itemsrequired | T[] | — | The rows. |
headersrequired | TableHeader[] | — | Vuetify headers: title, key, align, sortable, nowrap, width… |
item-value | string | "id" | The unique key of each row. |
sort-icon | string | "chevrons-up-down" | Icon of a sortable column. |
sort-asc-icon | string | "chevron-up" | Icon of an ascending sort. |
sort-desc-icon | string | "chevron-down" | Icon of a descending sort. |
searchable | boolean | false | Shows the search field; / focuses it. |
show-columns-menu | boolean | false | Lets the user hide, show and reorder columns. |
show-filters | boolean | false | Shows the filters menu. |
show-grouping | boolean | false | Shows the group menu. |
hide-footer | boolean | false | Hides the pagination. |
disable-pagination | boolean | false | Shows every row. |
items-per-page-options | number[] | DEFAULT_ITEMS_PER_PAGE_OPTIONS | Page sizes offered. |
all-rows-option | boolean | false | Adds an “All” page size. |
row-actions | TableRowAction<T>[] | [] | Actions of the row menu: { icon, label, color?, disabled?, onClick }. |
bulk-actions | TableBulkAction[] | [] | Actions of the selection bar: { icon, label, color?, onClick }. |
locked-columns | string[] | [] | Columns that cannot be hidden. |
excluded-columns | string[] | [] | Columns left out of the columns menu. |
responsive-columns | Record<string, number> | {} | { key: minWidth }: hides a column while the table is narrower than that width. |
groupable-columns | string[] | — | Columns offered in the group menu. |
filters | TableFilter[] | [] | Filter definitions: text, select, radio, boolean, range or dateRange. |
loading | boolean | false | Shows skeleton rows. |
loading-rows | number | 5 | How many skeleton rows. |
row-label | ((item: T) => string) | — | Accessible name of each clickable row, such as the record id and name; screen readers announce it when the row gets focus. |
mobile-layout | TableMobileLayout | "stack" | — | Phone row built from existing cells: { primary, value?, status?, details? } with column keys, or stack to keep label and value pairs. |
v-model | unknown[] | [] | The selected row values. |
search | string | "" | The search text. Use v-model:search. |
filter-values | TableFilterValues | {} | The filter values. Use v-model:filter-values. |
sort-by | TableSortItem[] | [] | The sort, such as [{ key: 'issued', order: 'desc' }]. Bind it with v-model:sort-by to a ref: a plain :sort-by resets on every render. |
group-by | TableSortItem[] | [] | The grouping. Use v-model:group-by. |
Slots
Name | Slot props | Description |
|---|---|---|
#group-header | GroupHeaderSlot | A custom group row. |
#no-data | any | Replaces the default empty state. By default an empty table shows a small BaseEmptyState; with a search or filters active it says nothing matches and offers Clear search and Reset filters. |
#body | VDataTableSlotProps<any> | Replaces the rows, for card grids. |
#header-actions | any | Controls in the toolbar, such as views. |
#row-actions | { item: T; } | Replaces the row menu; receives item. |
#bulk-actions | { selected: unknown[]; clear: () => void; } | Replaces the bulk actions; receives selected and clear. |
#mobile-row | { item: T; } | Replaces each row on phones (when the table stacks) with your own compact layout, usually a BaseDataTableMobileRow; receives item. It wins over mobile-layout. |
Events
Name | Payload | Description |
|---|---|---|
@update:modelValue | [value: unknown[]] | — |
@update:search | [value: string] | — |
@update:filterValues | [value: TableFilterValues] | — |
@update:sortBy | [value: TableSortItem[]] | — |
@update:groupBy | [value: TableSortItem[]] | — |
Every item.<key> slot of Vuetify works to render a cell, as in the examples.
With @click:row, the rows are one tab stop: only the current row is focusable, and j/k or the arrows move between rows. Pressing j anywhere on the page focuses the current row of the first clickable table (the first row until you move), k its last row; neither fires inside a dialog, a menu or a drawer. Enter or Space opens the row and x selects it when the table has show-select.