Skip to content

Table

Table is a responsive data table with loading skeleton rows, empty state, and named cell slots for custom rendering.

Basic usage

Tailwind v4
vue
<script setup>
import { ref } from 'vue'

const columns = [
  { key: 'name', label: 'Name' },
  { key: 'status', label: 'Status' },
  { key: 'location', label: 'Location' },
  { key: 'updated', label: 'Last Updated', align: 'right' },
]

const rows = ref([
  { id: 1, name: 'Crusher #1', status: 'Running',  location: 'Pit A',   updated: 'Jun 9' },
  { id: 2, name: 'Crusher #2', status: 'Down',     location: 'Pit A',   updated: 'Jun 8' },
  { id: 3, name: 'Screen #1',  status: 'Running',  location: 'Plant 1', updated: 'Jun 10' },
])
</script>

<template>
  <Table :columns="columns" :rows="rows">
    <template #cell-status="{ value }">
      <Badge :variant="value === 'Running' ? 'success' : 'danger'">{{ value }}</Badge>
    </template>
  </Table>
</template>

Custom cell rendering

Use #cell-<key> slots to render custom content in any column. The slot receives { row, value }:

vue
<Table :columns="columns" :rows="rows">
  <template #cell-status="{ row }">
    <Badge :variant="row.status === 'Running' ? 'success' : 'danger'">
      {{ row.status }}
    </Badge>
  </template>
</Table>

Loading state

Tailwind v4
vue
<Table :columns="columns" :rows="[]" :loading="true" />

While loading is true, 5 skeleton rows are rendered instead of the data.

Empty state

Tailwind v4
vue
<Table :columns="columns" :rows="[]" empty="No equipment found" />

Column definition

Each column in the columns array accepts:

PropertyTypeRequiredDescription
keystringYesMaps to the row object key
labelstringYesColumn header text
widthstringNoCSS width, e.g. '120px' or '20%'
align'left' | 'center' | 'right'NoCell/header text alignment (default: 'left')

Props

PropTypeDefaultDescription
columnsTableColumn[]Column definitions
rowsRecord<string, unknown>[]Row data
loadingbooleanfalseShow skeleton rows
emptystring'No results'Empty state message

Slots

SlotSlot propsDescription
cell-<key>{ row, value }Custom cell renderer for column key

TypeScript

The TableColumn interface is exported from the package:

ts
import type { TableColumn } from '@jetpack-labs/jetpack-ui'

Private — Jetpack Labs internal use only