Styling, dark mode and RTL
vue
<template>
<div class="demo-options">
<label v-for="(_, name) in options" :key="name"><input v-model="options[name]" type="checkbox" /> {{ name }}</label>
</div>
<div :dir="options.rtl ? 'rtl' : 'ltr'">
<VTable
:columns="columns"
:data="products"
:striped="options.striped"
:hoverable="options.hoverable"
:bordered="options.bordered"
:dense="options.dense"
:stickyHeader="options.stickyHeader"
:maxHeight="options.stickyHeader ? '260px' : undefined"
:rowClass="(row) => (row.stock === 0 ? 'out-of-stock' : '')"
:texts="{ total: 'Products', rowsPerPage: 'Per page' }"
:pageSizeOptions="[10, 20]"
clientSide
/>
</div>
</template>
<script setup lang="ts">
import { reactive } from "vue";
import { VTable, type Column } from "v-table-system";
import { products } from "./data";
const options = reactive({ striped: true, hoverable: true, bordered: false, dense: false, stickyHeader: false, rtl: false });
const columns: Column[] = [
{ key: "id", label: "ID" },
{ key: "name", label: "Name" },
{ key: "stock", label: "Stock" },
];
</script>
<style>
.out-of-stock {
color: #e7515a;
}
</style>Appearance props
| Prop | Default | Description |
|---|---|---|
striped | true | Alternating row colours. |
hoverable | true | Highlights the row under the pointer. |
bordered | false | Borders around every cell. |
dense | false | Less vertical padding. |
stickyHeader | false | Keeps the header visible while the rows scroll. Use it with maxHeight. |
maxHeight | Any CSS height, such as "400px". The rows scroll inside it. | |
rowClass | A class for every row, or a function (row, index) => string to style some rows. |
Your own CSS
The styles are injected with the component and only touch the table itself, so they will not change the rest of your page. To override them, target the table's root class, .vts:
css
.vts {
font-family: "Inter", sans-serif;
}
.vts th {
background: #1e293b;
color: white;
}Dark mode
The dark colours apply when the table is inside an element with the class dark, usually <html class="dark">. Tailwind CSS uses the same convention. Try the theme switch at the top of this page.
Right-to-left
Put the table inside an element with dir="rtl", or set it on <html>. Text alignment, the pagination arrows and the spacing follow the direction.
Texts
Every built-in text can be replaced, for translation or wording, with the texts prop. Only pass the ones you want to change.
vue
<VTable
:texts="{
total: 'الإجمالي',
search: 'بحث ...',
noData: 'لا توجد بيانات',
rowsPerPage: 'عدد الصفوف',
exportCsv: 'تصدير CSV',
selected: 'محدد',
filterPlaceholder: 'اختر الفلتر',
}"
/>| Key | Default |
|---|---|
total | Total |
search | Search ... |
filterPlaceholder | Select filter value |
noData | No data available |
rowsPerPage | Rows per page |
exportCsv | Export CSV |
selected | selected |