Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Data

DataTable

Render rows, filters, sorting, selection, and pagination from column definitions.

Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.

Interactive showcase

Try server loading and retry
Destination
Delivery
Payment
Destination
Payment
ORD-2048
Mira Laurent
3€128.00Luxembourg
Delivered on time
Paid

Activity for ORD-2048

Mira Laurent · Luxembourg

  1. Order delivered

    Destination
    Luxembourg
    Status
    Delivered
    Delivery update
    Delivered on time
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2048-LU
    Destination
    Luxembourg
    Status
    In transit
  3. Payment captured

    Amount
    €128.00
    Status
    Paid
    Payment method
    Visa ···· 2048
    Processed by
    Payment service
  4. Order confirmed

    Items
    3 items
    Order total
    €128.00
    Confirmation
    CONF-2048
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2048
    Source
    Online store
    Customer
    Mira Laurent
ORD-2049
Noah Weber
1€64.00Belgium
2 days late
Paid

Activity for ORD-2049

Noah Weber · Belgium

  1. Delivery rescheduled

    Destination
    Belgium
    Status
    Rescheduled
    Delivery update
    2 days late
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2049-LU
    Destination
    Belgium
    Status
    In transit
  3. Payment captured

    Amount
    €64.00
    Status
    Paid
    Payment method
    Visa ···· 2049
    Processed by
    Payment service
  4. Order confirmed

    Items
    1 item
    Order total
    €64.00
    Confirmation
    CONF-2049
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2049
    Source
    Online store
    Customer
    Noah Weber
ORD-2050
Ava Martin
2€89.00France
On schedule
Pending

Activity for ORD-2050

Ava Martin · France

  1. Delivery scheduled

    Destination
    France
    Status
    Scheduled
    Delivery update
    On schedule
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2050-LU
    Destination
    France
    Status
    In transit
  3. Awaiting payment

    Amount
    €89.00
    Status
    Pending
    Payment method
    Visa ···· 2050
    Processed by
    Payment service
  4. Order confirmed

    Items
    2 items
    Order total
    €89.00
    Confirmation
    CONF-2050
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2050
    Source
    Online store
    Customer
    Ava Martin
ORD-2051
Leo Klein
4€214.00Germany
On schedule
Paid

Activity for ORD-2051

Leo Klein · Germany

  1. Delivery scheduled

    Destination
    Germany
    Status
    Scheduled
    Delivery update
    On schedule
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2051-LU
    Destination
    Germany
    Status
    In transit
  3. Payment captured

    Amount
    €214.00
    Status
    Paid
    Payment method
    Visa ···· 2051
    Processed by
    Payment service
  4. Order confirmed

    Items
    4 items
    Order total
    €214.00
    Confirmation
    CONF-2051
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2051
    Source
    Online store
    Customer
    Leo Klein
ORD-2052
Sofia Rossi
2€76.00Luxembourg
1 day late
Pending

Activity for ORD-2052

Sofia Rossi · Luxembourg

  1. Delivery rescheduled

    Destination
    Luxembourg
    Status
    Rescheduled
    Delivery update
    1 day late
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2052-LU
    Destination
    Luxembourg
    Status
    In transit
  3. Awaiting payment

    Amount
    €76.00
    Status
    Pending
    Payment method
    Visa ···· 2052
    Processed by
    Payment service
  4. Order confirmed

    Items
    2 items
    Order total
    €76.00
    Confirmation
    CONF-2052
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2052
    Source
    Online store
    Customer
    Sofia Rossi
Items per page

Edit null

Install

The complete example also uses Avatar, Chip, IconButton, Dialog, Sheet, ActivityTimeline, and DescriptionList. Install these families to run it unchanged.

Run in your project
bunx --bun @getweini/cli@latest add data-table avatar chip icon-button dialog sheet activity-timeline description-list alert spinner

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Destination
Delivery
Payment
Destination
Payment
ORD-2048
Mira Laurent
3€128.00Luxembourg
Delivered on time
Paid

Activity for ORD-2048

Mira Laurent · Luxembourg

  1. Order delivered

    Destination
    Luxembourg
    Status
    Delivered
    Delivery update
    Delivered on time
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2048-LU
    Destination
    Luxembourg
    Status
    In transit
  3. Payment captured

    Amount
    €128.00
    Status
    Paid
    Payment method
    Visa ···· 2048
    Processed by
    Payment service
  4. Order confirmed

    Items
    3 items
    Order total
    €128.00
    Confirmation
    CONF-2048
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2048
    Source
    Online store
    Customer
    Mira Laurent
ORD-2049
Noah Weber
1€64.00Belgium
2 days late
Paid

Activity for ORD-2049

Noah Weber · Belgium

  1. Delivery rescheduled

    Destination
    Belgium
    Status
    Rescheduled
    Delivery update
    2 days late
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2049-LU
    Destination
    Belgium
    Status
    In transit
  3. Payment captured

    Amount
    €64.00
    Status
    Paid
    Payment method
    Visa ···· 2049
    Processed by
    Payment service
  4. Order confirmed

    Items
    1 item
    Order total
    €64.00
    Confirmation
    CONF-2049
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2049
    Source
    Online store
    Customer
    Noah Weber
ORD-2050
Ava Martin
2€89.00France
On schedule
Pending

Activity for ORD-2050

Ava Martin · France

  1. Delivery scheduled

    Destination
    France
    Status
    Scheduled
    Delivery update
    On schedule
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2050-LU
    Destination
    France
    Status
    In transit
  3. Awaiting payment

    Amount
    €89.00
    Status
    Pending
    Payment method
    Visa ···· 2050
    Processed by
    Payment service
  4. Order confirmed

    Items
    2 items
    Order total
    €89.00
    Confirmation
    CONF-2050
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2050
    Source
    Online store
    Customer
    Ava Martin
ORD-2051
Leo Klein
4€214.00Germany
On schedule
Paid

Activity for ORD-2051

Leo Klein · Germany

  1. Delivery scheduled

    Destination
    Germany
    Status
    Scheduled
    Delivery update
    On schedule
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2051-LU
    Destination
    Germany
    Status
    In transit
  3. Payment captured

    Amount
    €214.00
    Status
    Paid
    Payment method
    Visa ···· 2051
    Processed by
    Payment service
  4. Order confirmed

    Items
    4 items
    Order total
    €214.00
    Confirmation
    CONF-2051
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2051
    Source
    Online store
    Customer
    Leo Klein
ORD-2052
Sofia Rossi
2€76.00Luxembourg
1 day late
Pending

Activity for ORD-2052

Sofia Rossi · Luxembourg

  1. Delivery rescheduled

    Destination
    Luxembourg
    Status
    Rescheduled
    Delivery update
    1 day late
    Updated by
    Delivery team
  2. Shipment dispatched

    Carrier
    ParcelPost
    Tracking number
    TRK-2052-LU
    Destination
    Luxembourg
    Status
    In transit
  3. Awaiting payment

    Amount
    €76.00
    Status
    Pending
    Payment method
    Visa ···· 2052
    Processed by
    Payment service
  4. Order confirmed

    Items
    2 items
    Order total
    €76.00
    Confirmation
    CONF-2052
  5. Order reviewed

    Reviewed by
    Alex Morgan
    Outcome
    Approved
    Checks completed
    Inventory reserved and delivery address verified.
  6. Order created

    Order reference
    ORD-2052
    Source
    Online store
    Customer
    Sofia Rossi
Items per page

Edit null

Vue
<script setup lang="ts">
import { nextTick, ref, useId } from 'vue'
import ActivityTimeline from './components/ui/activity-timeline/ActivityTimeline.vue'
import type { ActivityTimelineEntry } from './components/ui/activity-timeline/types'
import Avatar from './components/ui/avatar/Avatar.vue'
import AvatarFallback from './components/ui/avatar/AvatarFallback.vue'
import Button from './components/ui/button/Button.vue'
import Chip from './components/ui/chip/Chip.vue'
import DataTable from './components/ui/data-table/DataTable.vue'
import DataTableCell from './components/ui/data-table/DataTableCell.vue'
import type { DataTableBulkAction, DataTableColumn } from './components/ui/data-table/types'
import DescriptionList from './components/ui/description-list/DescriptionList.vue'
import DescriptionListItem from './components/ui/description-list/DescriptionListItem.vue'
import Dialog from './components/ui/dialog/Dialog.vue'
import DialogBody from './components/ui/dialog/DialogBody.vue'
import DialogClose from './components/ui/dialog/DialogClose.vue'
import DialogContent from './components/ui/dialog/DialogContent.vue'
import DialogFooter from './components/ui/dialog/DialogFooter.vue'
import DialogHeader from './components/ui/dialog/DialogHeader.vue'
import DialogTitle from './components/ui/dialog/DialogTitle.vue'
import IconButton from './components/ui/icon-button/IconButton.vue'
import Input from './components/ui/input/Input.vue'
import Sheet from './components/ui/sheet/Sheet.vue'
import SheetBody from './components/ui/sheet/SheetBody.vue'
import SheetContent from './components/ui/sheet/SheetContent.vue'
import SheetDescription from './components/ui/sheet/SheetDescription.vue'
import SheetFooter from './components/ui/sheet/SheetFooter.vue'
import SheetHeader from './components/ui/sheet/SheetHeader.vue'
import SheetTitle from './components/ui/sheet/SheetTitle.vue'
import SheetTrigger from './components/ui/sheet/SheetTrigger.vue'

interface Order {
  id: string
  customer: { name: string; initials: string }
  items: number
  total: number
  destination: string
  deliveryDate: string
  deliveryNote: string
  deliveryDelayed: boolean
  payment: 'Paid' | 'Pending' | 'Refunded'
}

const deliveryDateFormat = new Intl.DateTimeFormat('en-GB', {
  day: 'numeric',
  month: 'short',
  year: 'numeric',
  timeZone: 'UTC',
})
function formatDeliveryDate(value: string) {
  return deliveryDateFormat.format(new Date(`${value}T00:00:00Z`))
}

const orders = ref<Order[]>([
  {
    id: 'ORD-2048',
    customer: { name: 'Mira Laurent', initials: 'ML' },
    items: 3,
    total: 128,
    destination: 'Luxembourg',
    deliveryDate: '2026-09-24',
    deliveryNote: 'Delivered on time',
    deliveryDelayed: false,
    payment: 'Paid',
  },
  {
    id: 'ORD-2049',
    customer: { name: 'Noah Weber', initials: 'NW' },
    items: 1,
    total: 64,
    destination: 'Belgium',
    deliveryDate: '2026-09-26',
    deliveryNote: '2 days late',
    deliveryDelayed: true,
    payment: 'Paid',
  },
  {
    id: 'ORD-2050',
    customer: { name: 'Ava Martin', initials: 'AM' },
    items: 2,
    total: 89,
    destination: 'France',
    deliveryDate: '2026-09-29',
    deliveryNote: 'On schedule',
    deliveryDelayed: false,
    payment: 'Pending',
  },
  {
    id: 'ORD-2051',
    customer: { name: 'Leo Klein', initials: 'LK' },
    items: 4,
    total: 214,
    destination: 'Germany',
    deliveryDate: '2026-10-01',
    deliveryNote: 'On schedule',
    deliveryDelayed: false,
    payment: 'Paid',
  },
  {
    id: 'ORD-2052',
    customer: { name: 'Sofia Rossi', initials: 'SR' },
    items: 2,
    total: 76,
    destination: 'Luxembourg',
    deliveryDate: '2026-09-27',
    deliveryNote: '1 day late',
    deliveryDelayed: true,
    payment: 'Pending',
  },
  {
    id: 'ORD-2053',
    customer: { name: 'Eli Dubois', initials: 'ED' },
    items: 1,
    total: 42,
    destination: 'France',
    deliveryDate: '2026-09-23',
    deliveryNote: 'Delivered on time',
    deliveryDelayed: false,
    payment: 'Refunded',
  },
  {
    id: 'ORD-2054',
    customer: { name: 'Lina Hoffmann', initials: 'LH' },
    items: 3,
    total: 151,
    destination: 'Germany',
    deliveryDate: '2026-10-02',
    deliveryNote: 'On schedule',
    deliveryDelayed: false,
    payment: 'Paid',
  },
])

const editingId = ref<string | null>(null)
const editOpen = ref(false)
const editFormId = useId()
const customerInputId = useId()
const draftName = ref('')
function editOrder(row: Order) {
  editingId.value = row.id
  draftName.value = row.customer.name
  editOpen.value = true
}
function saveOrder() {
  if (!editingId.value || !draftName.value.trim()) return
  orders.value = orders.value.map((row) =>
    row.id === editingId.value
      ? { ...row, customer: { ...row.customer, name: draftName.value.trim() } }
      : row,
  )
  editOpen.value = false
}
const pendingHistoryEdit = ref<Order | null>(null)
function editFromHistory(row: Order, close: () => void) {
  pendingHistoryEdit.value = row
  close()
}
async function finishHistoryClose(row: Order) {
  if (pendingHistoryEdit.value?.id !== row.id) return
  const pending = pendingHistoryEdit.value
  pendingHistoryEdit.value = null
  await nextTick()
  editOrder(pending)
}
const chipColors = {
  default: 'var(--primary)',
  secondary: 'var(--secondary-foreground)',
  success: 'var(--success)',
  warning: 'var(--warning)',
} as const

interface ActivityDetail {
  label: string
  value: string
  span?: 'full'
  tone?: keyof typeof chipColors
  numeric?: boolean
}
const moneyFormat = new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'EUR' })
const activityTimeFormat = new Intl.DateTimeFormat('en-GB', {
  day: 'numeric',
  month: 'short',
  year: 'numeric',
  hour: '2-digit',
  minute: '2-digit',
  timeZone: 'UTC',
})
function activityDetails(row: Order, item: ActivityTimelineEntry): ActivityDetail[] {
  const id = String(item.id)
  if (id.endsWith('-delivery'))
    return [
      { label: 'Destination', value: row.destination },
      {
        label: 'Status',
        value: row.deliveryDelayed
          ? 'Rescheduled'
          : row.deliveryNote === 'Delivered on time'
            ? 'Delivered'
            : 'Scheduled',
        tone: row.deliveryDelayed ? 'warning' : 'success',
      },
      { label: 'Delivery update', value: row.deliveryNote, span: 'full' },
      { label: 'Updated by', value: 'Delivery team' },
    ]
  if (id.endsWith('-dispatch'))
    return [
      { label: 'Carrier', value: 'ParcelPost' },
      { label: 'Tracking number', value: `TRK-${row.id.slice(4)}-LU`, numeric: true },
      { label: 'Destination', value: row.destination },
      { label: 'Status', value: 'In transit', tone: 'default' },
    ]
  if (id.endsWith('-payment'))
    return [
      { label: 'Amount', value: moneyFormat.format(row.total), numeric: true },
      {
        label: 'Status',
        value: row.payment,
        tone:
          row.payment === 'Paid' ? 'success' : row.payment === 'Pending' ? 'warning' : 'secondary',
      },
      { label: 'Payment method', value: `Visa ···· ${row.id.slice(4)}` },
      { label: 'Processed by', value: 'Payment service' },
    ]
  if (id.endsWith('-confirmed'))
    return [
      { label: 'Items', value: `${row.items} ${row.items === 1 ? 'item' : 'items'}` },
      { label: 'Order total', value: moneyFormat.format(row.total), numeric: true },
      { label: 'Confirmation', value: `CONF-${row.id.slice(4)}`, span: 'full' },
    ]
  if (id.endsWith('-reviewed'))
    return [
      { label: 'Reviewed by', value: 'Alex Morgan' },
      { label: 'Outcome', value: 'Approved', tone: 'success' },
      {
        label: 'Checks completed',
        value: 'Inventory reserved and delivery address verified.',
        span: 'full',
      },
    ]
  return [
    { label: 'Order reference', value: row.id, numeric: true },
    { label: 'Source', value: 'Online store' },
    { label: 'Customer', value: row.customer.name, span: 'full' },
  ]
}

const bulkActions: DataTableBulkAction<Order>[] = [
  {
    label: 'Mark paid',
    onClick: (rows) => {
      const ids = new Set(rows.map((row) => row.id))
      orders.value = orders.value.map((row) =>
        ids.has(row.id) ? { ...row, payment: 'Paid' } : row,
      )
    },
  },
]

// Fluent UI System Icons, regular 20px glyphs. These SVG paths belong to this example.
function orderActivity(row: Order): ActivityTimelineEntry[] {
  const at = (daysBefore: number, time: string) => {
    const date = new Date(`${row.deliveryDate}T${time}:00Z`)
    date.setUTCDate(date.getUTCDate() - daysBefore)
    return { datetime: date.toISOString(), timestamp: `${activityTimeFormat.format(date)} UTC` }
  }
  return [
    {
      id: `${row.id}-delivery`,
      title: row.deliveryDelayed
        ? 'Delivery rescheduled'
        : row.deliveryNote === 'Delivered on time'
          ? 'Order delivered'
          : 'Delivery scheduled',
      tone: row.deliveryDelayed ? 'warning' : 'success',
      ...at(0, '14:20'),
    },
    { id: `${row.id}-dispatch`, title: 'Shipment dispatched', tone: 'info', ...at(1, '08:45') },
    {
      id: `${row.id}-payment`,
      title:
        row.payment === 'Paid'
          ? 'Payment captured'
          : row.payment === 'Pending'
            ? 'Awaiting payment'
            : 'Payment refunded',
      tone: row.payment === 'Paid' ? 'success' : row.payment === 'Pending' ? 'warning' : 'info',
      ...at(2, '16:05'),
    },
    { id: `${row.id}-confirmed`, title: 'Order confirmed', tone: 'info', ...at(2, '11:30') },
    { id: `${row.id}-reviewed`, title: 'Order reviewed', tone: 'success', ...at(3, '10:18') },
    { id: `${row.id}-placed`, title: 'Order created', tone: 'default', ...at(3, '09:12') },
  ]
}

const headerIcons: Record<string, string> = {
  actions:
    'M6.25 10a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0m5 0a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0M15 11.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5',
  id: 'M6 2a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V7.41c0-.4-.16-.78-.44-1.06l-3.91-3.91A1.5 1.5 0 0 0 10.59 2zM5 4a1 1 0 0 1 1-1h4v3.5c0 .83.67 1.5 1.5 1.5H15v8a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1zm9.8 3h-3.3a.5.5 0 0 1-.5-.5V3.2z',
  customer:
    'M10 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8M7 6a3 3 0 1 1 6 0 3 3 0 0 1-6 0m-2 5a2 2 0 0 0-2 2c0 1.7.83 2.97 2.13 3.8A9 9 0 0 0 10 18c1.85 0 3.58-.39 4.87-1.2A4.4 4.4 0 0 0 17 13a2 2 0 0 0-2-2zm-1 2a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1c0 1.3-.62 2.28-1.67 2.95A8 8 0 0 1 10 17a8 8 0 0 1-4.33-1.05A3.4 3.4 0 0 1 4 13',
  items:
    'M11.3 2.48a3.5 3.5 0 0 0-2.6 0l-5.76 2.3A1.5 1.5 0 0 0 2 6.18v7.64c0 .62.37 1.17.94 1.4l5.76 2.3a3.5 3.5 0 0 0 2.6 0l5.76-2.3c.57-.23.94-.78.94-1.4V6.18a1.5 1.5 0 0 0-.94-1.4zm-2.23.93a2.5 2.5 0 0 1 1.86 0l5.22 2.09-2.27.91-6.16-2.46zm-2.7 1.08 6.16 2.46L10 7.96 3.85 5.5zm4.13 4.35 6.5-2.6v7.58a.5.5 0 0 1-.31.47l-5.76 2.3q-.2.09-.43.13zm-1 0v7.88a3 3 0 0 1-.43-.13l-5.76-2.3a.5.5 0 0 1-.31-.47V6.24z',
  total:
    'M7 9a2 2 0 1 1 4 0 2 2 0 0 1-4 0m2-1a1 1 0 1 0 0 2 1 1 0 0 0 0-2M3.5 4C2.67 4 2 4.67 2 5.5v7c0 .83.67 1.5 1.5 1.5h11c.83 0 1.5-.67 1.5-1.5v-7c0-.83-.67-1.5-1.5-1.5zM3 5.5c0-.28.22-.5.5-.5H5v1a1 1 0 0 1-1 1H3zM3 8h1a2 2 0 0 0 2-2V5h6v1c0 1.1.9 2 2 2h1v2h-1a2 2 0 0 0-2 2v1H6v-1a2 2 0 0 0-2-2H3zm10-3h1.5c.28 0 .5.22.5.5V7h-1a1 1 0 0 1-1-1zm2 6v1.5a.5.5 0 0 1-.5.5H13v-1a1 1 0 0 1 1-1zM5 13H3.5a.5.5 0 0 1-.5-.5V11h1a1 1 0 0 1 1 1zm12-.5a2.5 2.5 0 0 1-2.5 2.5H4.09c.2.58.76 1 1.41 1h9a3.5 3.5 0 0 0 3.5-3.5v-5c0-.65-.42-1.2-1-1.41z',
  destination:
    'M5.05 4.05a7 7 0 1 1 9.9 9.9l-1.13 1.12-2.43 2.37a2 2 0 0 1-2.64.12l-.14-.12-2.04-1.99-1.52-1.5a7 7 0 0 1 0-9.9m9.2.7a6 6 0 0 0-8.67 8.32l.17.18.58.57 2.98 2.9.09.08a1 1 0 0 0 1.2 0l.1-.08 2.22-2.17 1.32-1.3.18-.18a6 6 0 0 0-.18-8.31M10 6.26a2.75 2.75 0 1 1 0 5.5 2.75 2.75 0 0 1 0-5.5m0 1a1.75 1.75 0 1 0 0 3.5 1.75 1.75 0 0 0 0-3.5',
  deliveryDate:
    'M7 11a1 1 0 1 0 0-2 1 1 0 0 0 0 2m1 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m2-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2m1 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m2-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2m4-5.5A2.5 2.5 0 0 0 14.5 3h-9A2.5 2.5 0 0 0 3 5.5v9A2.5 2.5 0 0 0 5.5 17h9a2.5 2.5 0 0 0 2.5-2.5zM4 7h12v7.5c0 .83-.67 1.5-1.5 1.5h-9A1.5 1.5 0 0 1 4 14.5zm1.5-3h9c.83 0 1.5.67 1.5 1.5V6H4v-.5C4 4.67 4.67 4 5.5 4',
  payment:
    'M13.5 13a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1zM2 6.75A2.75 2.75 0 0 1 4.75 4h10.5A2.75 2.75 0 0 1 18 6.75v6.5A2.75 2.75 0 0 1 15.25 16H4.75A2.75 2.75 0 0 1 2 13.25zM4.75 5C3.78 5 3 5.78 3 6.75V8h14V6.75C17 5.78 16.22 5 15.25 5zM17 9H3v4.25c0 .97.78 1.75 1.75 1.75h10.5c.97 0 1.75-.78 1.75-1.75z',
}

const editIcon =
  'M17.18 2.93a2.97 2.97 0 0 0-4.26-.06l-9.37 9.38q-.5.5-.66 1.2l-.88 3.94a.5.5 0 0 0 .6.6l3.93-.87c.46-.1.9-.34 1.23-.68l9.36-9.36a2.97 2.97 0 0 0 .05-4.15m-3.55.65a1.97 1.97 0 1 1 2.8 2.8l-.68.66-2.8-2.79zm-1.38 1.38 2.8 2.8-7.99 7.97q-.31.31-.74.41l-3.16.7.7-3.18q.1-.41.4-.7z'
const paymentIcons = {
  Paid: 'M3.37 10.17a.5.5 0 0 0-.74.66l4 4.5c.19.22.52.23.72.02l10.5-10.5a.5.5 0 0 0-.7-.7L7.02 14.27z',
  Pending:
    'M10 2a8 8 0 1 1 0 16 8 8 0 0 1 0-16m0 1a7 7 0 1 0 0 14 7 7 0 0 0 0-14m-.5 2a.5.5 0 0 1 .5.41V10h2.5a.5.5 0 0 1 .09 1H9.5a.5.5 0 0 1-.5-.41V5.5c0-.28.22-.5.5-.5',
  Refunded:
    'M5 2.5a.5.5 0 0 0-1 0v4.9c0 .33.27.6.6.6h4.9a.5.5 0 0 0 0-1H5.9l3.48-3.02a4 4 0 0 1 5.25 6.04l-8.17 7.1a.5.5 0 0 0 .65.76l8.17-7.1a5 5 0 0 0-6.56-7.55L5 6.46z',
}
const historyIcon =
  'M10 4a6 6 0 1 1-5.98 5.54.5.5 0 1 0-1-.08L3 10a7 7 0 1 0 2-4.9V3.5a.5.5 0 0 0-1 0v3c0 .28.22.5.5.5h3a.5.5 0 0 0 0-1H5.53c1.1-1.23 2.7-2 4.47-2m0 2.5a.5.5 0 0 0-1 0v4c0 .28.22.5.5.5h3a.5.5 0 0 0 0-1H10z'

const columns: DataTableColumn<Order>[] = [
  { key: 'id', label: 'Order', width: 120, sortable: true, hideable: false },
  {
    key: 'customer',
    label: 'Customer',
    width: 140,
    sortable: true,
    accessor: (row) => row.customer.name,
  },
  {
    key: 'items',
    label: 'Items',
    align: 'end',
    width: 120,
    format: { type: 'number' },
    sortable: true,
    filter: { type: 'numberRange' },
  },
  {
    key: 'total',
    label: 'Total',
    align: 'end',
    tabularNums: true,
    width: 120,
    format: { type: 'currency', currency: 'EUR' },
    sortable: true,
    filter: { type: 'numberRange' },
  },
  {
    key: 'destination',
    label: 'Destination',
    width: 118,
    filter: {
      type: 'searchableSelect',
      primary: true,
      options: ['Luxembourg', 'Belgium', 'France', 'Germany'].map((value) => ({
        label: value,
        value,
      })),
    },
  },
  {
    key: 'deliveryDate',
    label: 'Delivery',
    width: 144,
    sortable: true,
    filter: { type: 'dateRange', primary: true },
  },
  {
    key: 'payment',
    label: 'Payment',
    width: 104,
    align: 'start',
    filter: {
      type: 'select',
      primary: true,
      options: ['Paid', 'Pending', 'Refunded'].map((value) => ({ label: value, value })),
    },
  },
  {
    key: 'actions',
    label: '',
    align: 'end',
    width: 92,
    hideable: false,
    resizable: false,
    searchable: false,
  },
]
</script>

<template>
  <div class="w-full">
    <DataTable
      :data="orders"
      :columns="columns"
      :initial-state="{ itemsPerPage: 5 }"
      :page-sizes="[5, 10, 25]"
      :bulk-actions="bulkActions"
      selection
      search
      pagination
      resizable
      size="sm"
      aria-label="Orders"
      class="[&_[data-resize-handle]::before]:hidden [&_[data-resize-handle]:hover]:bg-primary/10 [&_[data-resize-handle][data-state=dragging]]:bg-primary/10"
    >
      <template #header-prefix="{ column }">
        <svg
          v-if="column.key !== 'actions'"
          aria-hidden="true"
          viewBox="0 0 20 20"
          fill="currentColor"
          class="size-4"
        >
          <path :d="headerIcons[column.key]" />
        </svg>
      </template>
      <template #default="{ row }">
        <DataTableCell column="customer" :title="row.customer.name">
          <div class="flex items-center gap-2.5">
            <Avatar size="sm">
              <AvatarFallback aria-hidden="true">{{ row.customer.initials }}</AvatarFallback>
            </Avatar>
            <span class="min-w-0 truncate font-medium">{{ row.customer.name }}</span>
          </div>
        </DataTableCell>
        <DataTableCell column="deliveryDate" :title="`${row.deliveryDate} · ${row.deliveryNote}`">
          <div class="flex flex-col items-start gap-0.5">
            <time :datetime="row.deliveryDate" class="whitespace-nowrap font-medium">
              {{ formatDeliveryDate(row.deliveryDate) }}
            </time>
            <span class="text-xs text-muted-foreground">{{ row.deliveryNote }}</span>
          </div>
        </DataTableCell>
        <DataTableCell column="payment">
          <Chip
            :color="chipColors[row.payment === 'Paid' ? 'success' : row.payment === 'Pending' ? 'warning' : 'secondary']"
          >
            <template #prefix>
              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor">
                <path :d="paymentIcons[row.payment]" />
              </svg>
            </template>
            {{ row.payment }}
          </Chip>
        </DataTableCell>
        <DataTableCell column="actions" title="Order actions">
          <div class="flex items-center justify-end gap-1">
            <IconButton label="Edit" variant="ghost" size="sm" @click="editOrder(row)">
              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor">
                <path :d="editIcon" />
              </svg>
            </IconButton>
            <Sheet>
              <SheetTrigger as-child>
                <IconButton label="View history" variant="ghost" size="sm">
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor">
                    <path :d="historyIcon" />
                  </svg>
                </IconButton>
              </SheetTrigger>
              <SheetContent v-slot="{ close }" class="text-start" @close="finishHistoryClose(row)">
                <SheetHeader>
                  <SheetTitle>{{ `Activity for ${row.id}` }}</SheetTitle>
                  <SheetDescription>
                    {{ `${row.customer.name} · ${row.destination}` }}
                  </SheetDescription>
                </SheetHeader>
                <SheetBody>
                  <ActivityTimeline
                    :items="orderActivity(row)"
                    :aria-label="`Activity for ${row.id}`"
                  >
                    <template #content="{ item }">
                      <DescriptionList :columns="2">
                        <DescriptionListItem
                          v-for="field in activityDetails(row, item)"
                          :key="field.label"
                          :label="field.label"
                          :span="field.span ?? 1"
                        >
                          <Chip v-if="field.tone" :color="chipColors[field.tone]">
                            {{ field.value }}
                          </Chip>
                          <span v-else :class="field.numeric ? 'tabular-nums' : undefined">
                            {{ field.value }}
                          </span>
                        </DescriptionListItem>
                      </DescriptionList>
                    </template>
                  </ActivityTimeline>
                </SheetBody>
                <SheetFooter>
                  <Button variant="outline" class="flex-1" @click="close">Close</Button>
                  <Button class="flex-1" @click="editFromHistory(row, close)">Edit order</Button>
                </SheetFooter>
              </SheetContent>
            </Sheet>
          </div>
        </DataTableCell>
      </template>
    </DataTable>
  </div>
  <Dialog v-model:open="editOpen">
    <DialogContent size="sm">
      <DialogHeader><DialogTitle>{{ `Edit ${editingId}` }}</DialogTitle></DialogHeader>
      <DialogBody>
        <form :id="editFormId" @submit.prevent="saveOrder">
          <label :for="customerInputId" class="mb-1 block text-sm font-medium">Customer</label>
          <Input :id="customerInputId" v-model="draftName" data-dialog-initial-focus />
        </form>
      </DialogBody>
      <DialogFooter>
        <DialogClose as-child><Button variant="outline">Cancel</Button></DialogClose>
        <Button type="submit" :form="editFormId">Save</Button>
      </DialogFooter>
    </DialogContent>
  </Dialog>
</template>

This eight-column orders table uses Avatar and Chip in custom cells, fixed widths, currency formatting, header icons, colored payment chips, readable delivery dates, and drag-to-resize headers. Click a heading to sort, then Shift-click another to add a sort level. Its last column has Edit and History icon buttons; Edit opens a Dialog editor and History opens a Sheet containing that row’s ActivityTimeline using the same outlined detail cards and structured DescriptionList fields as its own docs. Its six sample events cover creation, review, confirmation, payment, dispatch, and delivery, with one Edit order action in the sheet footer. Selection supports a bulk action across pages. The toolbar shows three quick filters; open Filters for item and total ranges. Install avatar, chip, icon-button, dialog, sheet, activity-timeline, and description-list alongside data-table to reuse the full example.

When to use it

Order dashboard

Show customer identity, delivery timing, and payment status in one sortable table.

Filtered report

Put frequent filters in the toolbar and less common filters in the Filters dropdown.

More examples

Search and filter

Column definitions generate the filter controls and sorting.

Search and filter
<script setup lang="ts">
import DataTable from './components/ui/data-table/DataTable.vue'
import type { DataTableColumn } from './components/ui/data-table/types'

interface User {
  id: number
  name: string
  status: string
  country: string
}
const users: User[] = [
  { id: 1, name: 'Ivan', status: 'Active', country: 'Luxembourg' },
  { id: 2, name: 'Mira', status: 'Pending', country: 'Belgium' },
  { id: 3, name: 'Noah', status: 'Active', country: 'France' },
]
// Fluent UI System Icons, regular 20px glyphs. These SVG paths belong to this example.
const headerIcons: Record<string, string> = {
  name: 'M10 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8M7 6a3 3 0 1 1 6 0 3 3 0 0 1-6 0m-2 5a2 2 0 0 0-2 2c0 1.7.83 2.97 2.13 3.8A9 9 0 0 0 10 18c1.85 0 3.58-.39 4.87-1.2A4.4 4.4 0 0 0 17 13a2 2 0 0 0-2-2zm-1 2a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1c0 1.3-.62 2.28-1.67 2.95A8 8 0 0 1 10 17a8 8 0 0 1-4.33-1.05A3.4 3.4 0 0 1 4 13',
  status:
    'M10 2a8 8 0 1 1 0 16 8 8 0 0 1 0-16m0 1a7 7 0 1 0 0 14 7 7 0 0 0 0-14m3.36 4.65c.17.17.2.44.06.63l-.06.07-4 4a.5.5 0 0 1-.64.07l-.07-.06-2-2a.5.5 0 0 1 .63-.77l.07.06L9 11.3l3.65-3.65c.2-.2.51-.2.7 0',
  country:
    'M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16m0-15c.66 0 1.4.59 2.02 1.9q.33.71.56 1.6H7.42q.23-.89.56-1.6C8.59 3.6 9.34 3 10 3M7.07 4.49q-.4.9-.68 2.01H3.94A7 7 0 0 1 7.7 3.38q-.36.5-.64 1.1M6.2 7.5a16 16 0 0 0 0 5H3.46a7 7 0 0 1 0-5zm.2 6q.26 1.12.68 2.01.28.61.64 1.1a7 7 0 0 1-3.77-3.11zm1.03 0h5.16a9 9 0 0 1-.56 1.6C11.41 16.4 10.66 17 10 17s-1.4-.59-2.02-1.9q-.33-.71-.56-1.6m5.37-1H7.21a15 15 0 0 1 0-5h5.58a15 15 0 0 1 0 5m.82 1h2.45a7 7 0 0 1-3.77 3.12q.36-.5.64-1.1.4-.9.68-2.02m2.93-1h-2.73a16 16 0 0 0 0-5h2.73a7 7 0 0 1 0 5m-4.25-9.12a7 7 0 0 1 3.77 3.12h-2.45a11 11 0 0 0-.68-2.01q-.28-.61-.64-1.1',
}

const columns: DataTableColumn<User>[] = [
  {
    key: 'name',
    label: 'Name',
    sortable: true,
    filter: { type: 'text', primary: true },
  },
  {
    key: 'status',
    label: 'Status',
    filter: {
      type: 'select',
      primary: true,
      options: [
        { label: 'Active', value: 'Active' },
        { label: 'Pending', value: 'Pending' },
      ],
    },
  },
  {
    key: 'country',
    label: 'Country',
    filter: { type: 'text' },
  },
]
</script>
<template>
  <DataTable :data="users" :columns="columns" search pagination aria-label="Filtered users">
    <template #header-prefix="{ column }">
      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" class="size-4">
        <path :d="headerIcons[column.key]" />
      </svg>
    </template>
  </DataTable>
</template>

Custom delivery cell

Replace only the delivery column with a formatted date and a small delivery note; the other columns stay automatic.

Custom delivery cell
<script setup lang="ts">
import DataTable from './components/ui/data-table/DataTable.vue'
import DataTableCell from './components/ui/data-table/DataTableCell.vue'
import type { DataTableColumn } from './components/ui/data-table/types'

interface Order {
  id: string
  customer: string
  deliveryDate: string
  deliveryDelayed: boolean
  delayDays: number
}

const deliveryDateFormat = new Intl.DateTimeFormat('en-GB', {
  day: 'numeric',
  month: 'short',
  year: 'numeric',
  timeZone: 'UTC',
})
function formatDeliveryDate(value: string) {
  return deliveryDateFormat.format(new Date(`${value}T00:00:00Z`))
}

const orders: Order[] = [
  {
    id: 'ORD-2048',
    customer: 'Mira Laurent',
    deliveryDate: '2026-09-24',
    deliveryDelayed: false,
    delayDays: 0,
  },
  {
    id: 'ORD-2049',
    customer: 'Noah Weber',
    deliveryDate: '2026-09-26',
    deliveryDelayed: true,
    delayDays: 2,
  },
]
// Fluent UI System Icons, regular 20px glyphs. These SVG paths belong to this example.
const headerIcons: Record<string, string> = {
  id: 'M6 2a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V7.41c0-.4-.16-.78-.44-1.06l-3.91-3.91A1.5 1.5 0 0 0 10.59 2zM5 4a1 1 0 0 1 1-1h4v3.5c0 .83.67 1.5 1.5 1.5H15v8a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1zm9.8 3h-3.3a.5.5 0 0 1-.5-.5V3.2z',
  customer:
    'M10 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8M7 6a3 3 0 1 1 6 0 3 3 0 0 1-6 0m-2 5a2 2 0 0 0-2 2c0 1.7.83 2.97 2.13 3.8A9 9 0 0 0 10 18c1.85 0 3.58-.39 4.87-1.2A4.4 4.4 0 0 0 17 13a2 2 0 0 0-2-2zm-1 2a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1c0 1.3-.62 2.28-1.67 2.95A8 8 0 0 1 10 17a8 8 0 0 1-4.33-1.05A3.4 3.4 0 0 1 4 13',
  deliveryDate:
    'M7 11a1 1 0 1 0 0-2 1 1 0 0 0 0 2m1 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m2-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2m1 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m2-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2m4-5.5A2.5 2.5 0 0 0 14.5 3h-9A2.5 2.5 0 0 0 3 5.5v9A2.5 2.5 0 0 0 5.5 17h9a2.5 2.5 0 0 0 2.5-2.5zM4 7h12v7.5c0 .83-.67 1.5-1.5 1.5h-9A1.5 1.5 0 0 1 4 14.5zm1.5-3h9c.83 0 1.5.67 1.5 1.5V6H4v-.5C4 4.67 4.67 4 5.5 4',
}

const columns: DataTableColumn<Order>[] = [
  { key: 'id', label: 'Order' },
  {
    key: 'deliveryDate',
    label: 'Delivery',
    sortable: true,
  },
]
</script>
<template>
  <DataTable :data="orders" :columns="columns" aria-label="Order delivery">
    <template #header-prefix="{ column }">
      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" class="size-4">
        <path :d="headerIcons[column.key]" />
      </svg>
    </template>
    <template #default="{ row }">
      <!-- Match the column key to replace only that cell. Other columns render automatically. -->
      <DataTableCell column="deliveryDate">
        <div class="flex flex-col items-start gap-0.5">
          <time :datetime="row.deliveryDate" class="whitespace-nowrap font-medium">
            {{ formatDeliveryDate(row.deliveryDate) }}
          </time>
          <span class="text-xs text-muted-foreground">
            {{ row.deliveryDelayed ? `${row.delayDays} days late` : 'On time' }}
          </span>
        </div>
      </DataTableCell>
    </template>
  </DataTable>
</template>

Alignment and numeric digits

Use align for both the heading and body cells, then use headerAlign or cellAlign when those need to differ. Numeric digits use equal-width tabular figures by default in automatic and custom cells; tabularNums can change that per column or per custom DataTableCell. The scoped header-prefix and header-suffix slots receive { column } and place application-owned content around the visible label. The showcase uses the docs app’s Fluent icons; copyable examples include the matching Fluent SVG paths.

Alignment and numeric digits
<script setup lang="ts">
import DataTable from './components/ui/data-table/DataTable.vue'
import DataTableCell from './components/ui/data-table/DataTableCell.vue'
import type { DataTableColumn } from './components/ui/data-table/types'

interface ReportRow {
  region: string
  orders: number
  variance: number
  reportedAt: string
}

const rows: ReportRow[] = [
  { region: 'North', orders: 1240, variance: 18.4, reportedAt: '09:30' },
  { region: 'Central', orders: 980, variance: -3.2, reportedAt: '09:30' },
  { region: 'South', orders: 760, variance: 7.1, reportedAt: '09:30' },
]

// Fluent UI System Icons, regular 20px glyphs. These SVG paths belong to this example.
const headerIcons: Record<string, string> = {
  region:
    'M5 13h11.5a.5.5 0 0 0 .42-.78L14.1 8l2.82-4.22A.5.5 0 0 0 16.5 3h-12a.5.5 0 0 0-.5.5v14a.5.5 0 0 0 1 0zm0-1V4h10.57l-2.49 3.72a.5.5 0 0 0 0 .56L15.57 12z',
  orders:
    'M11.3 2.48a3.5 3.5 0 0 0-2.6 0l-5.76 2.3A1.5 1.5 0 0 0 2 6.18v7.64c0 .62.37 1.17.94 1.4l5.76 2.3a3.5 3.5 0 0 0 2.6 0l5.76-2.3c.57-.23.94-.78.94-1.4V6.18a1.5 1.5 0 0 0-.94-1.4zm-2.23.93a2.5 2.5 0 0 1 1.86 0l5.22 2.09-2.27.91-6.16-2.46zm-2.7 1.08 6.16 2.46L10 7.96 3.85 5.5zm4.13 4.35 6.5-2.6v7.58a.5.5 0 0 1-.31.47l-5.76 2.3q-.2.09-.43.13zm-1 0v7.88a3 3 0 0 1-.43-.13l-5.76-2.3a.5.5 0 0 1-.31-.47V6.24z',
  variance:
    'M17.96 5.3a.5.5 0 0 0-.46-.3h-6a.5.5 0 0 0 0 1h4.8l-5.8 5.8-2.15-2.15a.5.5 0 0 0-.7 0l-5.5 5.5a.5.5 0 0 0 .7.7L8 10.71l2.15 2.14c.2.2.5.2.7 0L17 6.71v4.79a.5.5 0 0 0 1 0v-6a1 1 0 0 0-.04-.2',
  reportedAt:
    'M10 2a8 8 0 1 1 0 16 8 8 0 0 1 0-16m0 1a7 7 0 1 0 0 14 7 7 0 0 0 0-14m-.5 2a.5.5 0 0 1 .5.41V10h2.5a.5.5 0 0 1 .09 1H9.5a.5.5 0 0 1-.5-.41V5.5c0-.28.22-.5.5-.5',
}

const columns: DataTableColumn<ReportRow>[] = [
  {
    key: 'region',
    label: 'Region',
    align: 'start',
    tabularNums: false,
  },
  {
    key: 'orders',
    label: 'Orders',
    format: { type: 'number' },
    align: 'center',
  },
  {
    key: 'variance',
    label: 'Variance',
    format: { type: 'number' },
    headerAlign: 'center',
    cellAlign: 'end',
  },
  {
    key: 'reportedAt',
    label: 'Reported at',
    align: 'start',
    headerAlign: 'end',
    cellAlign: 'center',
  },
]
</script>

<template>
  <DataTable :data="rows" :columns="columns" aria-label="Regional report">
    <template #header-prefix="{ column }">
      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" class="size-4">
        <path :d="headerIcons[column.key]" />
      </svg>
    </template>
    <template #default="{ row }">
      <DataTableCell column="variance" tabular-nums>
        <span dir="ltr" class="inline-block whitespace-nowrap">
          {{ `${row.variance > 0 ? '+' : ''}${row.variance}%` }}
        </span>
      </DataTableCell>
    </template>
  </DataTable>
</template>

Loading and retry with server data

Click Refresh orders to see the loading state while the previous rows stay visible. Click Simulate a failed refresh, then Try again to recover. Type Atlas and quickly replace it with Beacon to see only the latest search take effect.

Loading orders…
Order
Loading and retry with server data
<script setup lang="ts">
import { useDataTable } from '@getweini/vue/primitives/data-table'
import { ref, watch } from 'vue'
import Alert from './components/ui/alert/Alert.vue'
import Button from './components/ui/button/Button.vue'
import DataTable from './components/ui/data-table/DataTable.vue'
import type { DataTableColumn } from './components/ui/data-table/types'
import Spinner from './components/ui/spinner/Spinner.vue'

const orders = [
  { id: '1001', customer: 'Atlas Studio' },
  { id: '1002', customer: 'Beacon Design' },
  { id: '1003', customer: 'Cedar Works' },
]
const columns: DataTableColumn<(typeof orders)[number]>[] = [
  { key: 'id', label: 'Order' },
  { key: 'customer', label: 'Customer', sortable: true },
]
const table = useDataTable({ columns })
const rows = ref<typeof orders>([])
const loaded = ref(false)
const pending = ref(true)
const failed = ref(false)
const request = ref({ fail: false })

function refresh(fail = false) {
  request.value = { fail }
}

watch(
  [table.apiParams, request],
  ([params, attempt], previous, onCleanup) => {
    const shouldFail = attempt !== previous?.[1] && attempt.fail
    failed.value = false
    pending.value = true
    const timer = setTimeout(() => {
      const search = String(params.search ?? '')
        .trim()
        .toLowerCase()
      if (shouldFail) {
        failed.value = true
      } else {
        const direction = String(params.orderBy ?? '').endsWith(':desc') ? -1 : 1
        rows.value = orders
          .filter((order) => !search || order.customer.toLowerCase().includes(search))
          .sort((a, b) => direction * a.customer.localeCompare(b.customer))
        loaded.value = true
      }
      pending.value = false
    }, 1200)
    onCleanup(() => clearTimeout(timer))
  },
  { immediate: true },
)
</script>

<template>
  <section class="w-full space-y-3">
    <div class="flex flex-wrap gap-2">
      <Button type="button" size="sm" variant="outline" @click="refresh()">Refresh orders</Button>
      <Button type="button" size="sm" variant="ghost" @click="refresh(true)">
        Simulate a failed refresh
      </Button>
    </div>
    <div v-if="!failed" role="status" class="flex min-h-6 items-center gap-2 text-sm">
      <template v-if="pending && loaded">
        <Spinner />
        Updating orders…
      </template>
      <template v-else-if="pending">Loading orders…</template>
      <template v-else>
        {{ rows.length }}
        {{ rows.length === 1 ? 'order' : 'orders' }} loaded
      </template>
    </div>
    <Alert v-else variant="destructive" role="alert" class="px-3! py-1!">
      <div class="flex flex-wrap items-center justify-between gap-x-3 text-sm">
        <p>Could not refresh orders.</p>
        <Button type="button" size="sm" variant="ghost" @click="refresh()">Try again</Button>
      </div>
    </Alert>
    <div :aria-busy="pending || undefined">
      <DataTable
        mode="server"
        :table="table"
        :data="rows"
        :columns="columns"
        :loading="pending && !loaded"
        search
        aria-label="Orders"
      />
    </div>
  </section>
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

DataTable

Complete API for DataTable
NameType or signatureDefaultWhat it does
datapropreadonly Row[]RequiredControls the data behavior of DataTable.
columnspropreadonly DataTableColumn<Row>[]RequiredDefine the columns shown in the table.
tablepropDataTableController<Row> | undefinedNot setControls the table behavior of DataTable.
modeprop"client" | "server" | undefined"client"Client mode derives local rows. Server mode renders the supplied page unchanged.
rowKeyprop(keyof Row & string) | ((row: Row) => DataTableId) | undefinedNot setControls the row key behavior of DataTable.
selectionpropboolean | undefinedNot setControls the selection behavior of DataTable.
paginationpropboolean | undefinedNot setControls the pagination behavior of DataTable.
totalpropnumber | undefinedNot setControls the total behavior of DataTable.
pageSizespropreadonly number[] | undefined[10, 25, 50]Controls the page sizes behavior of DataTable.
rowActionspropreadonly DataTableAction<Row>[] | undefinedNot setControls the row actions behavior of DataTable.
bulkActionspropreadonly DataTableBulkAction<Row>[] | undefinedNot setControls the bulk actions behavior of DataTable.
loadingpropboolean | undefinedNot setShow that an action is in progress and prevent repeat activation.
errorpropstring | Error | null | undefinedNot setControls the error behavior of DataTable.
initialStatepropPartial<DataTableState> | undefinedNot setControls the initial state behavior of DataTable.
localeTextpropDataTableLocaleTextOverrides | undefinedNot setOptional table UI translations. Missing entries fall back to the built-in English text.
sizeprop"sm" | "md" | "lg" | undefined"md"Choose the visual size. Medium is the usual default where available.
resizablepropboolean | undefinedNot setShow drag and keyboard resize handles on columns unless a column disables them.
columnWidthsmodelReadonly<Record<string, number>> | undefinedNot setOptional controlled widths in CSS pixels. Omit to keep widths local to this instance.
update:columnWidthsevent[widths: Record<string, number>]—Requests a new column widths value from the parent.
defaultslot((props: { row: Row; index: number; }) => unknown) | undefinedOptionalContent shown inside DataTable.
header-prefixslot((props: { column: DataTableColumn<Row>; }) => unknown) | undefinedOptionalContent for the header prefix area of DataTable.
header-suffixslot((props: { column: DataTableColumn<Row>; }) => unknown) | undefinedOptionalContent for the header suffix area of DataTable.
tableexposedDataTableController<Row>—Access table from a component template ref.

DataTableCell

Complete API for DataTableCell
NameType or signatureDefaultWhat it does
tabularNumspropboolean | undefinedundefinedControls the tabular nums behavior of DataTableCell.
alignprop"start" | "end" | "center" | undefinedNot setChoose how content aligns within its container.
columnpropstringRequiredControls the column behavior of DataTableCell.
defaultslot() => unknownRequiredContent shown inside DataTableCell.
Public type definitions
Public types
// packages/frameworks/vue/components/data-table/types.ts
import type {
  DataTableColumn,
  DataTableController,
  DataTableId,
  DataTableSelection,
  DataTableState,
} from '@getweini/vue/primitives/data-table'
import type { Component } from 'vue'

export type {
  DataTableColumn,
  DataTableController,
  DataTableFilter,
  DataTableFilterOption,
  DataTableFilterValue,
  DataTableId,
  DataTableParamNames,
  DataTableSelection,
  DataTableSort,
  DataTableState,
  DataTableUrlState,
  DataTableValueFormat,
  UseDataTableOptions,
} from '@getweini/vue/primitives/data-table'
export interface DataTableCellProps {
  column: string
  align?: 'start' | 'center' | 'end'
  /** Override the column's equal-width digit setting for this cell. */
  tabularNums?: boolean
}
export interface DataTableAction<Row> {
  label: string
  icon?: Component
  onClick: (row: Row) => void | Promise<void>
  disabled?: (row: Row) => boolean
}
export interface DataTableBulkAction<Row> {
  label: string
  /** rows and ids cover loaded selected rows; selection describes all matching server rows. */
  onClick: (rows: Row[], ids: DataTableId[], selection: DataTableSelection) => void | Promise<void>
}
export interface DataTableLocaleText {
  search: string
  clearSearch: string
  filters: string
  clearFilter: (label: string) => string
  resetFilters: string
  settings: string
  columns: string
  actions: string
  selectAll: string
  selectAllMatching: (count: number) => string
  allMatchingSelected: (count: number) => string
  selectRow: (index: number) => string
  selected: (count: number) => string
  clearSelection: string
  empty: string
  noResults: string
  loading: string
  error: string
  previous: string
  next: string
  page: (page: number) => string
  pagination: string
  itemsPerPage: string
  sortAscending: (label: string) => string
  sortDescending: (label: string) => string
  sortedAscending: (label: string) => string
  sortedDescending: (label: string) => string
  sortClear: (label: string) => string
  sortPriority: (priority: number) => string
  sortAdditiveHint: string
  resizeColumn: (label: string) => string
  booleanTrue: string
  booleanFalse: string
  rangeFrom: (label: string) => string
  rangeTo: (label: string) => string
  date: {
    calendarLabel: string
    previousMonth: string
    nextMonth: string
    chooseDate: string
    clearSelection: string
  }
  dateRange: {
    calendarLabel: string
    previousMonth: string
    nextMonth: string
    chooseDates: string
    chooseEndDate: string
    clearSelection: string
  }
}
export type DataTableLocaleTextOverrides = Partial<
  Omit<DataTableLocaleText, 'date' | 'dateRange'>
> & {
  date?: Partial<DataTableLocaleText['date']>
  dateRange?: Partial<DataTableLocaleText['dateRange']>
}
export interface DataTableProps<Row = Record<string, unknown>> {
  data: readonly Row[]
  columns: readonly DataTableColumn<Row>[]
  table?: DataTableController<Row>
  /** Client mode derives local rows. Server mode renders the supplied page unchanged. */
  mode?: 'client' | 'server'
  rowKey?: (keyof Row & string) | ((row: Row) => DataTableId)
  selection?: boolean
  search?: boolean
  pagination?: boolean
  total?: number
  pageSizes?: readonly number[]
  rowActions?: readonly DataTableAction<Row>[]
  bulkActions?: readonly DataTableBulkAction<Row>[]
  loading?: boolean
  error?: string | Error | null
  initialState?: Partial<DataTableState>
  /** Optional table UI translations. Missing entries fall back to the built-in English text. */
  localeText?: DataTableLocaleTextOverrides
  size?: 'sm' | 'md' | 'lg'
  /** Show drag and keyboard resize handles on columns unless a column disables them. */
  resizable?: boolean
  /** Optional controlled widths in CSS pixels. Omit to keep widths local to this instance. */
  columnWidths?: Readonly<Record<string, number>>
}


// packages/frameworks/vue/dist/vue/primitives/data-table/index.d.ts
import { type ComponentPublicInstance, type MaybeRefOrGetter } from 'vue';
export type DataTableId = string | number;
export type DataTableFilterValue = string | number | boolean | {
    from?: string | number;
    to?: string | number;
} | undefined;
export interface DataTableFilterOption {
    label: string;
    value: string | number | boolean;
}
export type DataTableFilter = {
    /** Backend field used when serializing API params. Defaults to the column key. */
    key?: string;
    primary?: boolean;
} & ({
    type: 'text' | 'number' | 'boolean' | 'date' | 'dateRange' | 'numberRange';
} | {
    type: 'select' | 'searchableSelect';
    options: MaybeRefOrGetter<readonly DataTableFilterOption[]>;
});
export type DataTableValueFormat = {
    type: 'number';
    locale?: string;
} | {
    type: 'currency';
    currency: string;
    locale?: string;
};
export interface DataTableColumn<Row = Record<string, unknown>> {
    key: string;
    label: string;
    /** Shared heading and cell alignment, following the reading direction. */
    align?: 'start' | 'center' | 'end';
    /** Override align for the heading only. */
    headerAlign?: 'start' | 'center' | 'end';
    /** Override align for body cells only. */
    cellAlign?: 'start' | 'center' | 'end';
    /** Equal-width digits in automatic and custom cells. Defaults to true. */
    tabularNums?: boolean;
    /** Formats automatic cells without changing alignment. Custom cells own their content. */
    format?: DataTableValueFormat;
    /** Pixel width and drag limits. The table keeps these widths stable while rows change. */
    width?: number;
    minWidth?: number;
    maxWidth?: number;
    /** Set false to disable this column's handle when DataTable is resizable. */
    resizable?: boolean;
    sortable?: boolean;
    /** Backend field used when serializing sort API params. Defaults to key. */
    sortKey?: string;
    filter?: DataTableFilter;
    hideable?: boolean;
    visible?: boolean;
    /** Include this column's logical value in global client-side search. Defaults to true. */
    searchable?: boolean;
    /** Resolves the logical value used by automatic cells, sorting, filtering, and search. */
    accessor?: (row: Row) => unknown;
}
export interface DataTableSort {
    key: string;
    direction: 'asc' | 'desc';
}
export interface DataTableState {
    page: number;
    itemsPerPage: number;
    search: string;
    sort: DataTableSort[];
    filters: Record<string, DataTableFilterValue>;
    visibility: Record<string, boolean>;
    selected: DataTableId[];
    /** Select every row matching the current query, including unloaded server pages. */
    allMatching: boolean;
    /** IDs deselected after allMatching was enabled. */
    excluded: DataTableId[];
}
export interface DataTableSelection {
    mode: 'ids' | 'allMatching';
    ids: DataTableId[];
    excludedIds: DataTableId[];
    total: number;
    query: Pick<DataTableState, 'search' | 'sort' | 'filters'>;
}
export interface DataTableParamNames {
    page?: string;
    itemsPerPage?: string;
    sort?: string;
    search?: string;
}
export interface DataTableUrlState {
    page?: boolean;
    itemsPerPage?: boolean;
    search?: boolean;
    sort?: boolean;
    filters?: boolean;
    /** Optional router adapter. The default uses history.replaceState in the browser. */
    read?: () => URLSearchParams;
    replace?: (query: URLSearchParams) => void | Promise<void>;
}
export interface UseDataTableOptions<Row = Record<string, unknown>> {
    columns: MaybeRefOrGetter<readonly DataTableColumn<Row>[]>;
    initialState?: Partial<DataTableState>;
    paramNames?: DataTableParamNames;
    transformParams?: (params: Record<string, string | number | boolean>) => Record<string, unknown>;
    urlState?: boolean | DataTableUrlState;
}
export declare function getDataTableValue<Row>(row: Row, column: DataTableColumn<Row>): unknown;
export declare function getDataTableAlignment<Row>(column: DataTableColumn<Row>): "center" | "start" | "end";
export declare function formatDataTableValue<Row>(value: unknown, column: DataTableColumn<Row>): string;
export declare function useDataTableColumnSizing(options?: {
    widths?: MaybeRefOrGetter<Readonly<Record<string, number>> | undefined>;
    controlled?: MaybeRefOrGetter<boolean>;
    onUpdate?: (widths: Record<string, number>) => void;
}): {
    widths: import("vue").ComputedRef<Readonly<Record<string, number>>>;
    resizing: import("vue").Ref<string | null, string | null>;
    widthFor: <Row>(column: DataTableColumn<Row>) => number;
    setWidth: <Row>(column: DataTableColumn<Row>, width: number) => void;
    resetWidth: <Row>(column: DataTableColumn<Row>) => void;
    limits: <Row>(column: DataTableColumn<Row>) => {
        min: number;
        max: number;
    };
    onPointerDown: <Row>(column: DataTableColumn<Row>, event: PointerEvent) => void;
    onPointerMove: <Row>(column: DataTableColumn<Row>, event: PointerEvent) => void;
    onPointerEnd: (event: PointerEvent) => void;
    onLostPointerCapture: () => void;
    onKeydown: <Row>(column: DataTableColumn<Row>, event: KeyboardEvent) => void;
};
export declare function useDataTableActionState<Key>(): {
    pending: import("vue").ShallowRef<Set<Key>, Set<Key>>;
    isPending: (key: Key) => boolean;
    run: (key: Key, action: () => void | Promise<void>) => void | Promise<void>;
};
export declare function useDataTableHeightReservation(options: {
    enabled: MaybeRefOrGetter<boolean>;
    resetKey: MaybeRefOrGetter<unknown>;
}): {
    setRoot: (value: Element | ComponentPublicInstance | null) => void;
    reservedHeight: import("vue").Ref<number, number>;
};
export declare function useDataTableToolbarFocus(options: {
    mode: MaybeRefOrGetter<string>;
    toolbar: MaybeRefOrGetter<HTMLElement | null>;
    filterLayer: MaybeRefOrGetter<HTMLElement | null>;
    bulkLayer: MaybeRefOrGetter<HTMLElement | null>;
}): void;
export declare function useDataTable<Row = Record<string, unknown>>(options: UseDataTableOptions<Row>): {
    state: import("vue").Ref<{
        page: number;
        itemsPerPage: number;
        search: string;
        sort: {
            key: string;
            direction: "asc" | "desc";
        }[];
        filters: Record<string, DataTableFilterValue>;
        visibility: Record<string, boolean>;
        selected: DataTableId[];
        allMatching: boolean;
        excluded: DataTableId[];
    }, DataTableState | {
        page: number;
        itemsPerPage: number;
        search: string;
        sort: {
            key: string;
            direction: "asc" | "desc";
        }[];
        filters: Record<string, DataTableFilterValue>;
        visibility: Record<string, boolean>;
        selected: DataTableId[];
        allMatching: boolean;
        excluded: DataTableId[];
    }>;
    columns: import("vue").ComputedRef<readonly DataTableColumn<Row>[]>;
    apiParams: import("vue").ComputedRef<Record<string, unknown>>;
    setSearch: (search: string) => void;
    setFilter: (key: string, value: DataTableFilterValue) => void;
    resetFilters: () => void;
    setSort: (key: string, additive?: boolean) => void;
    onSortKeydown: (key: string, event: KeyboardEvent) => void;
    setPage: (page: number) => void;
    setItemsPerPage: (itemsPerPage: number) => void;
    setVisible: (key: string, visible: boolean) => void;
    isVisible: (column: DataTableColumn<Row>) => boolean;
    setSelected: (id: DataTableId, selected: boolean) => void;
    selectPage: (ids: readonly DataTableId[], selected: boolean) => void;
    isSelected: (id: DataTableId) => boolean;
    selectAllMatching: () => void;
    resetSelection: () => void;
    reset: () => void;
};
export type DataTableController<Row = Record<string, unknown>> = ReturnType<typeof useDataTable<Row>>;
export declare function useDataTablePageClamp<Row>(options: {
    table: MaybeRefOrGetter<DataTableController<Row>>;
    enabled: MaybeRefOrGetter<boolean>;
    pageCount: MaybeRefOrGetter<number | undefined>;
}): void;

Implementation notes

  • Use a stable id or rowKey for every row.
  • To redesign a column, add DataTableCell as a direct child of the default scoped slot and set column to its key. The row supplies extra details such as deliveryDelayed without adding another visible column.
  • Set width on a column to choose its starting size. Pass resizable to allow drag and keyboard resizing. align controls heading and cell alignment together; headerAlign and cellAlign override them independently. All columns default to inline-start alignment; set align: 'end' for numeric columns.
  • Tabular digits are enabled by default for automatic and custom cells and give numerals equal character widths. They do not align decimal separators. Set column tabularNums: false to use proportional digits, or set tabularNums on DataTableCell to override one custom cell. Use header-prefix and header-suffix templates for app-owned icons or metadata, choosing content with column.key. Keep the accessible label in column.label, mark decorative icons aria-hidden, and keep slot content noninteractive for sortable headers.
  • Sortable headings respond across the cell except at the resize handle. Shift-click another heading to add a sort level. Active headings show a primary bottom border and one direction arrow; unsorted headings show both arrows. Full values are available from the cell title on hover; pass a custom title for rich cells. Pagination stays in place as pages get shorter.
  • The example’s actions column composes IconButton and SheetTrigger for Edit and History. The showcase uses horizontal row separators without vertical cell borders, inside the standard outer table border. The resize handles stay available without drawing a second line. Pass selection and bulkActions to select a page, then all matching rows across pages. Server bulk callbacks receive a selection descriptor with the query and any excluded IDs.
  • Use useDataTable with mode="server" when your API owns filtering and pagination.

Accessibility and localization

  • Give the table an accessible name when surrounding content does not identify it. Header sorting, filter controls, selection, and row actions are keyboard accessible.

Source contract and editing guidance