Skip to content
On this page

Table ​

The Component ​

Country
Value 1
Value 2
Value 3
Spain205035
France452060

Usage ​

This is a base table component that accepts an array of data and handles pagination internally. It displays a responsive pagination component below the table. It also handles sorting, with the column headers as sort buttons.

Table headers and cells can be customized using scoped slots with dynamic slot names. For column headers the slot name is 'header-' + column id and for row cells just the column id.

<template #[`header-${IDS.NAME}`]="col">
  <span class="font-bold">{{ col.name }}</span>
</template>

<template #[IDS.VALUE]="row">
  <span class="text-right">{{ row.value }}</span>
</template>

Component API ​

Data ​

// columns
[
  { id: "country", name: "Country" },
  { id: "val1", name: "Value 1" }
  ...
]

// rows
[
  { country: 'Spain', val1: 30 },
  { country: 'France', val1: 20 },
  ...
]

Props ​

NameDefaultDescriptionType
columns"[]"The columns as objects with id and nameArray
rows"[]"The rows as objects with keys as column idsArray
fixedColumnnullThe id of the column to keep fixed on scrollString
defaultSort"id"The id of the column to sort on by defaultString
defaultSortDir"ASC"The direction to sort on by default (ASC/DESC)String
prefix"-"A prefix to use for sort and dir keys in queryString
itemsPerPage10The number of results shown per pageNumber
rowClass"-"The class for all rowsString

Events ​

NameArgumentDescription
@selectrow objectEmitted when row is clicked

Dependencies ​

  • OTPagination component
  • heroicons
  • VueUse