Appearance
Table
The Component
| Country | Value 1 | Value 2 | Value 3 |
|---|---|---|---|
| Spain | 20 | 50 | 35 |
| France | 45 | 20 | 60 |
Del 1 al 2 de 4 resultados
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
| Name | Default | Description | Type |
|---|---|---|---|
| columns | "[]" | The columns as objects with id and name | Array |
| rows | "[]" | The rows as objects with keys as column ids | Array |
| fixedColumn | null | The id of the column to keep fixed on scroll | String |
| defaultSort | "id" | The id of the column to sort on by default | String |
| defaultSortDir | "ASC" | The direction to sort on by default (ASC/DESC) | String |
| prefix | "-" | A prefix to use for sort and dir keys in query | String |
| itemsPerPage | 10 | The number of results shown per page | Number |
| rowClass | "-" | The class for all rows | String |
Events
| Name | Argument | Description |
|---|---|---|
| @select | row object | Emitted when row is clicked |
Dependencies
OTPaginationcomponent- heroicons
- VueUse