WlTable
Behavior
| Team guide | Done | |
| Research plan | In progress |
Full example
<script setup lang="ts">
import { computed, ref } from "vue";
import { WlPill, WlTable, type WlTableSort, type WlTableSortFn } from "legato-ui";
interface MaterialRow { id: number; name: string; status: string }
const rows = computed<MaterialRow[]>(() => [
{ id: 1, name: "Team guide", status: "Done" },
{ id: 2, name: "Research plan", status: "In progress" }
]);
const sort = ref<WlTableSort | null>(null);
const selection = ref<PropertyKey[]>([]);
const expanded = ref<PropertyKey[]>([]);
const sortRows: WlTableSortFn<MaterialRow> = (value, order) => [...value].sort((left, right) => {
const result = (order.key === "name" ? left.name : left.status).localeCompare(order.key === "name" ? right.name : right.status);
return order.direction === "asc" ? result : -result;
});
</script>
<template>
<div class="wl-stack" data-space="md">
<WlTable
v-model:sort="sort"
v-model:selection="selection"
v-model:expanded="expanded"
:columns="[
{ key: 'name', label: 'Material', sortable: true },
{ key: 'status', label: 'Status', sortable: true }
]"
:value="rows"
row-key="id"
selection-mode="multiple"
caption="Team materials"
:sort-fn="sortRows"
:pt="{ root: { style: { overflowX: 'auto' } } }"
>
<template #cell-status="{ value }"><WlPill tone="info" :label="String(value)" /></template>
<template #expansion="{ row }"><p>{{ row.name }} · {{ row.status }}</p></template>
</WlTable>
</div>
</template>Appearance
| Team guide | Done | |
| Research plan | In progress |
Full example
<script setup lang="ts">
import { computed, ref } from "vue";
import { WlPill, WlTable, type WlTableSort, type WlTableSortFn } from "legato-ui";
interface MaterialRow { id: number; name: string; status: string }
const rows = computed<MaterialRow[]>(() => [
{ id: 1, name: "Team guide", status: "Done" },
{ id: 2, name: "Research plan", status: "In progress" }
]);
const sort = ref<WlTableSort | null>(null);
const selection = ref<PropertyKey[]>([]);
const expanded = ref<PropertyKey[]>([]);
const sortRows: WlTableSortFn<MaterialRow> = (value, order) => [...value].sort((left, right) => {
const result = (order.key === "name" ? left.name : left.status).localeCompare(order.key === "name" ? right.name : right.status);
return order.direction === "asc" ? result : -result;
});
</script>
<template>
<div class="wl-stack" data-space="md">
<WlTable
v-model:sort="sort"
v-model:selection="selection"
v-model:expanded="expanded"
:columns="[
{ key: 'name', label: 'Material', sortable: true },
{ key: 'status', label: 'Status', sortable: true }
]"
:value="rows"
row-key="id"
selection-mode="multiple"
caption="Team materials"
:sort-fn="sortRows"
:pt="{ root: { style: { overflowX: 'auto' } } }"
>
<template #cell-status="{ value }"><WlPill tone="info" :label="String(value)" /></template>
<template #expansion="{ row }"><p>{{ row.name }} · {{ row.status }}</p></template>
</WlTable>
</div>
</template>Example data
| Team guide | Done | |
| Research plan | In progress |
Full example
<script setup lang="ts">
import { computed, ref } from "vue";
import { WlPill, WlTable, type WlTableSort, type WlTableSortFn } from "legato-ui";
interface MaterialRow { id: number; name: string; status: string }
const rows = computed<MaterialRow[]>(() => [
{ id: 1, name: "Team guide", status: "Done" },
{ id: 2, name: "Research plan", status: "In progress" }
]);
const sort = ref<WlTableSort | null>(null);
const selection = ref<PropertyKey[]>([]);
const expanded = ref<PropertyKey[]>([]);
const sortRows: WlTableSortFn<MaterialRow> = (value, order) => [...value].sort((left, right) => {
const result = (order.key === "name" ? left.name : left.status).localeCompare(order.key === "name" ? right.name : right.status);
return order.direction === "asc" ? result : -result;
});
</script>
<template>
<div class="wl-stack" data-space="md">
<WlTable
v-model:sort="sort"
v-model:selection="selection"
v-model:expanded="expanded"
:columns="[
{ key: 'name', label: 'Material', sortable: true },
{ key: 'status', label: 'Status', sortable: true }
]"
:value="rows"
row-key="id"
selection-mode="multiple"
caption="Team materials"
:sort-fn="sortRows"
:pt="{ root: { style: { overflowX: 'auto' } } }"
>
<template #cell-status="{ value }"><WlPill tone="info" :label="String(value)" /></template>
<template #expansion="{ row }"><p>{{ row.name }} · {{ row.status }}</p></template>
</WlTable>
</div>
</template>Cells, empty state and loading
Columns, numeric, cell-title/cell-status, empty slot, loading, accessible scrolling and a custom table in default.
| Status | |||
|---|---|---|---|
| Done | 8 | ||
| In progress | 3 |
Click a material title. Hours use numeric alignment.
Selected: 0
| Section | Records |
|---|---|
| Documents | 2 |
Full example
<script setup lang="ts">
import { WlButton, WlPill, WlTable, type WlTableColumn, type WlTableSort, type WlTableSortFn } from "legato-ui";
import { computed, ref } from "vue";
interface MaterialRow { id: number; title: string; status: string; hours: number }
const state = ref<"ready" | "empty" | "loading">("ready");
const selected = ref("");
const selection = ref<PropertyKey[]>([]);
const sort = ref<WlTableSort | null>(null);
const columns = computed<readonly WlTableColumn<MaterialRow>[]>(() => [
{ key: "title", label: "Material", sortable: true },
{ key: "status", label: "Status", align: "center" },
{ key: "hours", label: "Hours", numeric: true, align: "end", sortable: true }
]);
const rows = computed<readonly MaterialRow[]>(() => [
{ id: 1, title: "Release plan", status: "done", hours: 8 },
{ id: 2, title: "Overview", status: "progress", hours: 3 }
]);
const sortRows: WlTableSortFn<MaterialRow> = (value, order) => [...value].sort((left, right) => {
const result = order.key === "hours" ? left.hours - right.hours : left.title.localeCompare(right.title);
return order.direction === "asc" ? result : -result;
});
</script>
<template>
<div class="wl-stack" data-space="lg" data-table-example="WlTable">
<div
class="wl-inline"
data-space="sm"
role="group"
aria-label="Table state"
><WlButton
v-for="item in (['ready', 'empty', 'loading'] as const)"
:key="item"
size="sm"
:aria-pressed="state === item"
@click="state = item"
>{{ { ready: "Data", empty: "Empty", loading: "Loading" }[item] }}</WlButton></div>
<div
class="showcase-table-scroll"
tabindex="0"
role="region"
aria-label="Materials table — horizontal scrolling"
>
<WlTable
v-model:sort="sort"
v-model:selection="selection"
:value="state === 'empty' ? [] : rows"
:columns="columns"
:loading="state === 'loading'"
row-key="id"
selection-mode="multiple"
sticky-header
caption="Team materials"
:sort-fn="sortRows"
:row-class="row => ({ 'showcase-table-done': row.status === 'done' })"
>
<template #header-hours="{ column }">{{ column.label }}</template>
<template #cell-title="{ value }"><WlButton
size="sm"
variant="link"
:disabled="state === 'loading'"
@click="selected = String(value)"
>{{ value }}</WlButton></template>
<template #cell-status="{ value }">
<WlPill
:tone="value === 'done' ? 'success' : 'info'"
:label="value === 'done' ? 'Done' : 'In progress'"
/>
</template>
<template #empty>
<div class="wl-stack" data-space="sm">
<span>{{ "No materials yet." }}</span>
<div><WlButton size="sm" @click="state = 'ready'">{{ "Restore list" }}</WlButton></div>
</div>
</template>
<template #loading>
<div class="wl-stack" data-space="sm">
<span role="status">{{ "Loading materials…" }}</span>
<WlButton size="sm" @click="state = 'ready'">{{ "Cancel" }}</WlButton>
</div>
</template>
</WlTable>
</div>
<p class="wl-text-small" role="status">
{{ selected
? "Selected material: " + selected
: "Click a material title. Hours use numeric alignment." }}
</p>
<p class="wl-text-small">{{ "Selected:" }} {{ selection.length }}</p>
<WlTable>
<table class="showcase-custom-table">
<caption>{{ "Default slot: custom table" }}</caption>
<thead>
<tr>
<th scope="col">{{ "Section" }}</th>
<th scope="col">{{ "Records" }}</th>
</tr>
</thead>
<tbody><tr><th scope="row">{{ "Documents" }}</th><td>2</td></tr></tbody>
</table>
</WlTable>
</div>
</template>
<style scoped>
.showcase-table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--wl-border); border-radius: var(--wl-corner-control); }
.showcase-table-scroll :deep(table) { min-width: 360px; }
.showcase-table-scroll:focus-visible { outline: 2px solid var(--wl-focus-color); outline-offset: 2px; }
.showcase-table-scroll :deep(.showcase-table-done) { font-weight: 600; }
.showcase-custom-table { width: 100%; border-collapse: collapse; text-align: left; }
.showcase-custom-table th, .showcase-custom-table td { padding: var(--wl-space-sm); border-bottom: 1px solid var(--wl-border); }
.showcase-custom-table caption { text-align: left; padding-bottom: var(--wl-space-sm); }
</style>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model:sort: WlTableSort |
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
value | readonly Row[] | [] | Readonly Row extends object list; interfaces without an index signature are supported. |
columns | readonly WlTableColumn< | Not set | readonly WlTableColumn<Row>[] validates row field keys. For a virtual column (actions), explicitly set kind: "virtual". Without columns, the default slot is used. |
loading | boolean | false | Loading state. |
density | WlDensity | "default" | — |
striped | boolean | false | — |
expandable | boolean | false | — |
emptyMessage | string | Not set | Empty-state text; falls back to WlConfig.locale.noData (No data in English). |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
rowKey | WlTableRowKey< | Not set | Field or callback resolving stable row identity across sorting and reordering. |
rowClass | WlTableRowClass< | Not set | Additional CSS classes, or a resolver returning classes for each row. |
caption | string | Not set | Visible table caption associated with the table. |
ariaLabel | string | Not set | Accessible name when an external label is not referenced. |
stickyHeader | boolean | false | Keep table column headers visible within a scrolling container. |
sortFn | WlTableSortFn< | Not set | Application sorting callback receiving readonly rows and returning their desired order. |
selectionMode | WlTableSelectionMode | Not set | Enable single or multiple row selection; the selection model stores row keys. |
Events
| Event | Payload | When emitted |
|---|---|---|
rowClick | [detail: WlTableRowClick< | Pointer click on the row outside its interactive controls. |
update:sort | WlTableSort | | Emitted when the component requests a model change; the payload is the next value. |
update:selection | PropertyKey[] | Emitted when the component requests a model change; the payload is the next value. |
update:expanded | PropertyKey[] | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?: (props: {}) => unknown; | Custom table content when columns are absent. |
empty | empty?: (props: {}) => unknown; | Custom content for an empty table. |
cell-<key> | — | Scope { row: Row, value: Row[key] }; virtual columns have value: unknown. |
loading | loading?: (props: {}) => unknown; | Replacement content while loading is active. |
caption | caption?: (props: {}) => unknown; | Custom accessible table caption. |
expansion | expansion?: (props: WlTableExpansionSlotProps< | Content of an expanded row. |
footer | footer?: (props: {}) => unknown; | Table footer rows and cells. |
cell-${string} | [name: `cell-${string}`]: ((props: WlTableCellSlotProps< | Virtual cell content; narrow unknown values for non-field column keys. |
header-${string} | [name: `header-${string}`]: ((props: WlTableHeaderSlotProps< | Custom column heading with the column and current sort state. |
cell-${Key} | { /** Cells for known row fields preserve the corresponding field value type. */ [Key in WlTableFieldKey< | Cells for known row fields preserve the corresponding field value type. |
header-${Key} | { /** Column headings for known row fields preserve their key domain. */ [Key in WlTableFieldKey< | Column headings for known row fields preserve their key domain. |
Pass-through: pt
Sections WlTable are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
expansionHeader | th.wl-table__disclosure | Row details disclosure. |
expansionToggleCell | td.wl-table__disclosure | Row details disclosure. |
expansionToggle | button.wl-table__expand | Row details disclosure. |
expansionRow | tr.wl-table__expansion | Row details disclosure. |
expansionCell | td.wl-table__td | Row details disclosure. |
footer | tfoot | Table footer. |
root | div.wl-table | The root section in WlConfig.pt.table configuration. |
table | table.wl-table__table | The table section in WlConfig.pt.table configuration. |
caption | caption.wl-table__caption | Accessible caption naming the table. |
thead | thead.wl-table__head | The thead section in WlConfig.pt.table configuration. |
selectionHeader | th.wl-table__th | Header cell containing the select-all checkbox. |
selectionInput | input | Native row checkbox/radio or header checkbox. |
headerCell | th.wl-table__th | Column header cell; sorting controls live inside it. |
sortButton | button.wl-table__sort | Column button that emits controlled sorting changes. |
tbody | tbody.wl-table__body | The tbody section in WlConfig.pt.table configuration. |
bodyRow | tr.wl-table__row | The bodyRow section in WlConfig.pt.table configuration. |
selectionCell | td.wl-table__td | Body cell containing a row-selection control. |
emptyMessage | tr | The emptyMessage section in WlConfig.pt.table configuration. |
emptyMessageCell | td.wl-table__empty-cell | The emptyMessageCell section in WlConfig.pt.table configuration. |
mask | div.wl-table__mask | The mask section in WlConfig.pt.table configuration. |
loadingIcon | span.wl-table__loading | The loadingIcon section in WlConfig.pt.table configuration. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Columns create native table/th scope=col. Pass the table name through pt.table aria-label or a caption in your own table.
- In cell slots, preserve row and column meaning. Give cell buttons clear names and disabled when their action is unavailable.
- Loading sets aria-busy. Empty explains missing data; on narrow screens, provide a horizontal scroll region accessible by Tab.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab / Shift+Tab | Move between enabled links, actions and form controls. |
| Enter / Space | Activate native actions; links follow with Enter. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model:sort. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.