Data display
Layout
DataTable
A data grid with sorting, selection, column resizing and virtualization, built from Column components. Use it for records people sort, select and compare.
For hundreds of rows, add virtualize and a scroll-height, such as scroll-height="400px". The table then draws only the rows in view, so sorting, selecting and scrolling stay fast. Past 150 rendered rows, rows also stop sliding into place as they sort.
Install
import { DataTable } from 'vael-ui'Playground
| Expand row |
|---|
checkbox
undefined
always
clone
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { DataTable, Column } from 'vael-ui'
const rows = [
{ id: 'r1', name: 'Mira Mitchell', role: 'Engineer', status: 'Active' },
{ id: 'r2', name: "Marcus O'Connor", role: 'Designer', status: 'Active' },
{ id: 'r3', name: 'Priya Nair', role: 'Product Manager', status: 'Invited' },
]
</script>
<template>
<DataTable :data="rows" row-key="id">
<template #columns="{ columnData }">
<Column :data="columnData" field="name" label="Name" />
<Column :data="columnData" field="role" label="Role" />
<Column :data="columnData" field="status" label="Status" />
</template>
</DataTable>
</template>Motion New
DataTable's body rows: values or hooks for row, and the list's stagger.
<DataTable
:motion="{ initial: { row: { opacity: 0, y: 8 } }, stagger: 0.04 }"
/>| Name | Type | Description |
|---|---|---|
initialexit | row | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
staggerleavingappear | number | 'pop' | 'hold' | boolean | Items coming in together start stagger seconds apart. A leaving item lifts out so the rest close the gap ('pop'), or keeps its space until it's gone ('hold'). appear: true also brings in the items already there when it mounts. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Table pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| EnterSpace | Cycles a sortable column through ascending, descending and unsorted, from its header button. |
| ArrowDownArrowUp | Moves focus to the next or previous row, with selectionMode="row". |
| HomeEnd | Moves focus to the first or last row, with selectionMode="row". |
| Space | Selects or clears the focused row, with selectionMode="row". |
| Enter | Selects or clears the focused row and fires row-click, with selectionMode="row". |
| ShiftArrowDownShiftArrowUp | Adds the focused row and the next or previous row to the selection, unless single is set. |
| EnterSpace | Shows or hides a row's expansion, from its expand button. |
| ArrowLeftArrowRight | Narrows or widens the column by 16 px, from its focused resize handle. |
| AltArrowLeftAltArrowRight | Moves a reorderable column one place, from its header. |
- The sorted column header sets
aria-sorttoascendingordescending, and each sortable header label is a<button>. A header click announces the new sort through a polite status region. The expand button hasaria-expanded, andaria-controlswhile open. - With row selection, the table is a
role="grid"and rows carryaria-selected. WithselectionMode="row", rows are one Tab stop with a rovingtabindex, and keys inside a cell’s own controls stay with them. In checkbox mode, each row’s Checkbox (a Radio withsingle) is named after its row, such as “Select row Alice”. - Resize handles are focusable
role="separator"elements. An always-mountedrole="status"region announces new column widths and positions, and reads “Loading…” whileloadingsetsaria-busy. - With
scrollHeight, the head and body are separate tables, so ARIA roles rebuild one table for screen readers. Right to left, ArrowLeft and ArrowRight swap.